How to extract only characters from alphanumeric string

I want to extract only characters (units) like cm, mm, kg from alphanumeric string for ex. @123cm, $44kg, &166mm etc.
I want only cm, kg, mm to be extract from above example.
Thanks in Advance!

Hi,

How about the following?

mc = System.Text.RegularExpressions.Regex.Matches(yourString,"(?<=\d)[A-Za-z]+")

Main.xaml (8.1 KB)

Regards,

Hi @Yoichi Thanks for the reply.
Actually currently i am going with below logic
CurrentRow(“Height”) = String.Join(“,”,Split(CurrentRow(“Height”).ToString,“,”).Select(Function(x)System.Text.RegularExpressions.Regex.Match(x,“[\d.]+”).Value.ToString).ToArray)
.
This logic is for extracting only numbers from string like $24kg or 456mmetc.
Now I want only ‘kg’ or ‘mm’ from above string using the same logic

Could you please tell me what modification is required in above query to achieve expected result ( only ‘mm’ or ‘kg’)

Hi,

I think this expression returns only numeric characters such as 24 or 456, right?

Now I want only ‘kg’ or ‘mm’ from above string using the same logic

Can you try the following?

String.Join(",",Split(CurrentRow("Height").ToString,",").Select(Function(x)System.Text.RegularExpressions.Regex.Match(x,"(?<=\d)[A-Za-z]+").Value.ToString).ToArray)

Regards,

Thanks @Yoichi . This worked

1 Like

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