Regex get anything before expression (including multiple lines)

Hi, I would like to get all text before the exact expression:
21.a Offer

e.g. with the sample string:

word1 word2
21.a Offer

It should get:
word1 word2

Btw. what kind of Regex does UiPath use (so I can better search Google in future)?
Thanks a lot


Try using this in two different assign statements,

System.Text.RegularExpressions.Regex.Replace(result, “\s+”, " ")

Regex.Match(result,"(?<=This is a computer generated Invoice.).*).Value


For your problem , simple split function will work.

  1. Split by “21.a” , it will return a string array
  2. get the 0th element from the array

To answer your 2nd question, Regular expression is not language specific. In UiPath you can use Is Watch activity for regular expression.

1 Like

Also replace 21.a Offer after?<=

@Tuhin_Samanta Aren’t there different standards for regex expressions? I saw solutions in the web that didn’t work for me in UiPath.

Yes, there are some different standards for that. But they are not unified. In UiPath you can use RegEx for C#. It should work.

1 Like

Thanks a lot for the advice :slight_smile:

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