How to Extract unique Alphabets from a string excluding numbers using "Match activity"

How to Extract unique Alphabets from a string excluding numbers using “Match activity”

Inputstr - THT123
Outputstr -TH

Hello,

Can you please try this:

System.Text.RegularExpressions.Regex.Match(InputString.ToString,“(?sim)[^\d])+”).Value

Thanks!
Athira

1 Like

Thanks for the reply Athira. I get the below error
21.10.5+Branch.support-v21.10.Sha.369f46199a0fa6287d86ab2534b6896019db01bc

Source: Message Box

Message: parsing “(?sim)[^\d])+” - Too many )'s.

Exception Type: System.ArgumentException

RemoteException wrapping System.ArgumentException: parsing “(?sim)[^\d])+” - Too many )'s.
at System.Text.RegularExpressions.RegexParser.ScanRegex()

Sorry, there was a small syntax error. Please try this:

System.Text.RegularExpressions.Regex.Match(InputString,“(?sim)[^\d]+”).Value

Thanks!

Thanks Athira ,now i m able to get the alphabets from the string ,however I need to have only the unique alphabets from the string
eg Input str =THHT123
OUTSTR = TH

hey

try with this
System.Text.RegularExpressions.Regex.Replace(test,"\d", " ").Trim

regards!

After getting only the alphabets, can you please try to use this:
String.Join(“”, InputString.Distinct())

Thanks!

@tharani.natarajan Try the below one

(\D)(?!.*\1)

It will give the unique alphabets in an input string. We can concat when we are retrieving using Matches activity

Please find the attached workflow below

Example.zip (2.6 KB)

Hi @tharani.natarajan ,

You could try with the below Alternative as well :

InputStr = "THT123"

Then, Below Expression should give you the Distinct Letters present in the String :

String.Join("",InputStr.Where(Function(x)Not(x.ToString.IsNumeric)).Distinct().ToArray())
1 Like

Hi,

Sorry for hijacking but can you explain the code below within the regex.
(?sim)

Ive seen it a few times and now im curious :thinking:

Thanks

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