Help with configuring regex to extract information from email


I’m wondering if someone can help me with configuring a regex expression.
I have recieved a body text from an email in outlook. From this body I have extracted a certain piece of information (String) and stored it in a variable.

Now I want to extract some other information from the email. And I want to use regex in order to get the data between this saved variable and some other text in the email that is just plain text.
I want to do something like this:

System.Text.RegularExpressions.Regex.Match(Mail,"((?<=Some text in the email).*(?=variableName))").Value

Is this possible? And where should I put the quotation marks when comparing with a variable, and not plain text?

(The regex code above is used in order to assign, a new variable, some information)

Best regards

Yes you can use a variable in lookbefore pattern.

Just concatenate your variable in between the pattern using + operator.

System.Text.RegularExpressions.Regex.Match(Mail,"((?<=Some text in the email).*(?="+variableName+"))").Value

1 Like

Thank you! It works. :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.