How to identify specific string in a mail body with Regular expressions?

I want to extract a specific string in the Mail body when the body contains this phrase "Reference User : ", next to this phrase user will provide his/her user id(not numbers either a single word or max of two words).
Can we extract that information using regular expressions?
Please help me with this.

I would recommend you look up a few regular expression tutorials. Regular expressions are very specific to how the input data is structured, so it is difficult to give general advice that will work across use cases. Here are a couple to get you started:

Hopefully to get you on the right path, you might consider starting with a regular expression like:

Reference User: (\w+(\s\w+)?)

This will look for text starting with Reference User: (space after the colon). Then get the next series of characters and optionally a whitespace followed by another series of characters.

Without seeing the data, it is hard to say if this will work. As this will always get the second word if it exist regardless if this is part of the user. So might need to make the regular expression more specific. Refer to the tutorials on how to do that.




You can using Regex and a look ahead.
Insert this Regex Pattern into a ‘Matches’ activity:
(?<=Reference User : )\w+\s*\w*

Then use an Assign activity like this:
Stringresult = MATCHESOUTPUTVARIABLE(0).tostring

Update capitals letters.

Check out my Regex MegaPost if you want to learn Regex.




Thank you very much @oddrationale and @Steven_McKeering for the information and update you provided.

1 Like