Regex pull before a $

I have something like the following:

Word Word Word 123abc456 $1,234.56

I need to extract the 123abc456. Sometimes it will be 123456 with no letters as well.

@Will_Tyler Try below regex.

String variable1 = System.Text.RegularExpressions.Regex.Match(“Word Word Word 123abc456 $1,234.56”,"(?<=Word Word Word).+(?=\$)").ToString.Trim

If you want to use variable instead of using string directly then try below one.

String str = “Word Word Word 123abc456 $1,234.56”

String variable1 = System.Text.RegularExpressions.Regex.Match(str,"(?<=Word Word Word).+(?=\$)").ToString.Trim

What if the “word word word” changes every time?

Hi @Will_Tyler,

can you try with this

Hi @Will_Tyler,

Try below pattern



1 Like

Thank you @Arivu96. Worked perfectly!

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