Regex to find words on next line until 1st comma

I am trying to find the words between “Who is sending this notice?” and the first comma on the next row, so trying to extract “Livermore Toyota” from the following sample text:

“Who is sending this notice?
Livermore Toyota, a company with whom you do business, has contracted with our company, ComplyAuto Privacy LLC, to send certain notifications required by the California Consumer Privacy Act of 2018 (CCPA) on Livermore Toyota’s behalf. ComplyAuto Privacy LLC is a cloud-based software that helps dealerships and related businesses automate CCPA compliance tasks, such as the sending of this notice.”

I have tried all of these options which work in Regex builder but return nothing as the end result.
Who is sending this notice?(?s)(.)^(.+?),
Who is sending this notice?(?s)(.
\r?\n.)^(.+?),
(?<=Who is sending this notice?)(?s)(.
?)^(.+?),
(?<=Who is sending this notice?)\n(.+?),

To assign output to string variable (also tried all of the above options):
system.text.RegularExpressions.Regex.Match(strEmailBody, “(?<=Who is sending this notice?)\n(.+?),”).Value.tostring

Result:
image

*also tried using Matches activity with all of the same options & getting same result. This appears to work in the test but also returns nothing:

Hi,

Can you try the following? we need to escape ? because of special character.

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=Who is sending this notice\?\r?\n)[^,]+").Value

Sample20221118-1aL.zip (2.6 KB)

Regards,

This is great! It is working perfectly. Thanks so much!

1 Like

Quick question - what does the question mark in: “\r?” do?

Hi,

In this case ? mark means zero or one time.
So, if you write regex pattern like notice?, this means “notic” or “notice”.
And \r?\n is for 2 types of linebreak : Windows style is CR+LF and Unix style is LF. \r?\n matches both style.

Regards,

Got it, thanks!

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