Substring to remove particular text


I have the below strings. I want to remove the “IExxxxxxxxxxxxxx” from each of them (the xxxxxxxxxxxxxx represents a 14 digit number using 0-9). also remove the blanks from before and after the remaining text.

GBBS INTEtIONAL IExxxxxxxxxxxxxx
DtErRRYGtUE FMS IExxxxxxxxxxxxxx
AID BRZtON FR IExxxxxxxxxxxxxx
C TTtENAM IExxxxxxxxxxxxxx
IExxxxxxxxxxxxxx GHUDWN SWS

Test with this:

Result = System.Text.RegularExpressions.Regex.Replace(inputString, "(\b| +)IE\d{14} *", "")


Update: Use the regular expression below instead if you don’t want a partial match of strings that start with IE followed by more than 14 digits:

(\b| +)IE\d{14}(\b| +)

Thank you for this. If i had the below string and wanted everything apart from the IE20092472946373. The Letters dont have to be IE either. it can be any 14 digit number that is preceded by two letters. And there is not always a space before it.

PUWL RITREYIE20092472946373

The regular expression should be " *\w{2}\d{14} *" if you want any two letters followed by 14 digits and partial match.


1 Like

Hi, This was working fine for me up until about 10 mins ago when i started to encounter this error

“Text is not a member of String”

Please rename your variable system to something else. When you write System.Text.RegularExpressions… UiPath confuses System with your variable system.

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