Help with Regex - Return True/False if pattern exists or not

Hi All,
I am working on a robot to scrape information from a website.
Fairly new to UiPath and absolute novice at RegEx.

I am scraping the data using the screen scraping activity and getting the full text.
After that, I am extracting the data from the extracted text using RegEx.
I figured out all the static patterns and those are all working perfectly.
But now I am stuck at a point and no too knowledgeable on complex RegEx logic.

So, coming to the problem.
I have the extracted text ready. It will have a fairly consistent pattern. I am looking to get a boolean output of true or false depending on the pattern exists or not.

Below is the sample of the text. Sorry for the faked data, but as the actual data may have personal contact details, I cannot share an accurate sample.

More Stuff Above (use of lookbehind may be necessary here as there is more text above)


FirstName MiddleName LastName

Street 1FantasyRoad FakeArea ImaginaryDrive
Street 2MadeupBuiling DummyAppartment
Zip Code12345
CityRandom City
ContacName of Contact
Phone+12 321546456


More Stuff Below which may contain another 'Street 2'

Now, my requirement is to get a true or false value if the pattern contains Street 2 after the RECIVER, Name and Street 1 as highlighted in bold below.


FirstName MiddleName LastName -\Name of Person. Can be multiple words.

Street 1FantasyRoad FakeArea ImaginaryDrive \-Line 1 of Address. Can be any number of words
'Street 2'MadeupBuiling DummyAppartment \-Line 2 of Address. Can be any number of words
Zip Code12345 \-Post Code of address
CityRandom City \- Name of city. Can be multiple words
StateAnyState \- Name of State
CountrySomeCountry \- Name of country
ContacName of Contact \- Name of contact person
Phone+12 321546456 \- Phone number of contact person \- Email of Contact person


More stuff below that could contain another 'Street 2'
1 Like


You can use Is Match Activity to check if a pattern exists or not.

For you usecase, something like β€œ(?<=FirstName\sMiddleName\sLastName).\nStreet\s1.\n)Street\s2” would work.


Can you try the following expression?

System.Text.RegularExpressions.Regex.IsMatch(yourString,"RECEIVER[\s\S]*?Name[\s\S]*?Street 1[\s\S]*?Street 2")

This returns True or False.


Hi Yoici,
Thanks for taking the time and suggesting an answer.

This regex may not work as there are new line characters between RECIEVER and then the name may be any number of words and again a new line with the street 1 address having any number of words and then a newline followed by Street 2.
The regex you have suggested does not look like it is taking the different word count in the name and street 1 section.

I figured it out myself.

This Regex works when tested on REGEX STORM.



This is FYI, as it’s already solved.

[\s\S]* means any characters. So it matches even linebreak and whitespace etc. So the above pattern will work, i think.


HI Yoichi,
Yes, you were correct.
It did work. Apologies. I am just starting out with UiPath and regex.

I tried your expression and it worked. The only problem was that it was also matching other Street 2s as well. So I modified it a little bit and then it worked perfectly.

Putting the code below in case someone else finds it useful.

(?<=RECEIVER[\s\S]*?[\s\S]Street 1[\s\S]*?)Street\s2(?=[\s\S]*?SENDER)
1 Like

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