How to use regex or some other way to remove a specific number from a string

I need to remove only the highlighted numbers:

“BELO HORIZ.ONTE, 8 DE NOVEMBRO DE 2005.MEIRE.SILVA@PORTOSEGURO.COM.BRÁPORTO SEGURO - COMPANHIA DE SEGUROS GERAISAV. CARANDAÍ Nº 878 BELO HORIZONTE/MG, CEP 30.130.060; REFERÊNCIA: APÓLICE DE SEGUROS FIANÇA LOCATÍCIA Nº 746.0191.206-3,”

@Kesya_Magalhaes

Welcome to the community

Is that a constant number then can use str.Replace("20","")

Else if you want a regex…please let us know what are the constnt strings or values in that given string so as to write the regex accordingly

Cheers

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"\b(19|20)(?=\d{2}\b)","")

Regards,

Hello @Kesya_Magalhaes , Welcome to UiPath Community.
Try this regex replace method

System.Text.RegularExpressions.Regex.Replace(YourString,"(?<=DE\s)\d{2}","").ToString.Trim

Hi @Kesya_Magalhaes ,

If the pattern or the logic of selecting the number is in this way - The Two digits of the First 4 digits found is supposed to be removed from the data.

Then, we could Check with the Regex Replace in the below way :

(new System.Text.RegularExpressions.Regex("\d{2}(\d{2})")).Replace(inputText,"$1",1)

Here, InputText is a string type variable containing your input data.

Visuals from Debug :
image

Let us know if there is a more specific logic that you would need to apply for the removal of that particular data.