Removing non numeric character in a string variable

Hi UiPath,

Is there an easy way to remove nonnumeric character in a string?

let say I have the string below:

105,467.000 SGD
94,340.000 USD

I want to remove the SGD and USD

please let me know

thanks!

2 Likes

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Replace(yourString,"[^.,\d]","")

Regards,

2 Likes

It works! thank you

1 Like

Hi @alvin.c.apostol26

How about this expression

System.Text.RegularExpressions.Regex.Replace(yourString,"[A-Z]+","").ToString

Regards
Gokul

Can you help me to improve my regex knowledge i did not understand this expression can you explain please ^ symbols use for start of string and dot is use for any charector but here how it use

Hi @Aleem_Khan ,

In .net regex, meta character inside square brackets is slight different with normal pattern.
For example, dot inside square brackets is not “any character” but just literal. Also ( is same. So it’s unnecessary to escape them in it.
Or - is special character only inside square brackets like [A-Z].

Hope this helps you.

Regards,

1 Like

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