Remove special characters at the string

*ABH445677-BH
These special characters will varu
Need to remove special character at front
And remove special character at end along with the preceeding characters

Output:
ABH445677

Hi @Demo_User

You can use the following RegEx for the same:

\b([A-Za-z0-9]+)-[A-Za-z0-9]+\b

image

Hope this helps,
Best Regards.

Returning blank value

@Demo_User

Well, in that case, you can use this pattern:

\b([A-Za-z0-9]+)

UiPath syntax will be like this:

outputData = System.Text.RegularExpressions.Regex.Match("ABH445677-BH","\b([A-Za-z0-9]+)").Groups(0).ToString

image

Hope this helps,
Best Regards.

1 Like

I hope this should work - Such a brilliant one.
:slight_smile:

1 Like

Hi @Demo_User

Try using the Regex expression:

[A-Z0-9]+(?=-)

Hope it works

Regards,

1 Like

@Demo_User

Another way

System.Text.RegularExpressions.Regex.Match(str,"\w+").Value - this will get only first matched so would get the exact string

Cheers

Hi @Demo_User

You can use the regex expression to extract the required data.
image

Hope it helps!!

1 Like

Hi @Demo_User

Try using the below regex expression
(?<=.?)([A-Z]+\d+)(?=.?)