Regex suggestions

I have the following type of string…[External] Action required: Approve the cea and lease approvals that Walt Bechtol submitted - SP2152 - 1016_2Q21_R3_ Volatile Room & Pilot Plant HVAC Improvements. My current Regex is \s+(\w[^- ]*\d+[$ - ]). However, if the number of digits after SP exceeds 7 then the regex excludes them. I am ONLY interested in the phrase on any submission of “SPXXXXX”. I tried substring but am unable because sometimes there is a [space]-[space] prior and after and sometimes there is only a - before and after. Any suggestions? Phrase will always begin with “SP”

Hi @Chris_Bolin - Please check the below pattern…Since you specified more than 7 should be excluded i have added \d{1,5} if this is not your requirement adjust it accordingly…

Hope this helps…

This is great…I didn’t even think of using a word boundary - sometimes I overthink and miss the simple. Thanks so much.

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