How to remove a special characters in a given string by regex

how to remove a special characters in a given string by regex?

“philippines nt., (Roosevelt Ave 3), St@a. philippines City, @U/SA”

Hello

Try this:
System.Text.RegularExpressions.Regex.Replace(yourStr, “[^a-z A-Z 0-9]”, “”)

Insert any extra values into the square brackets to keep them.

Cheers

Steve

Hi @sai_gupta

you can try this

1 Like

Hi,

It’s necessary to clarify definition of special character.
However, how about the following?

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

Regards,

@sai_gupta

You can use this, which replces any specia character

System.Text.RegularExpressions.Regex.Replace(str,"[^\w\s]","")

Cheers

HI try this way also

System.Text.RegularExpressions.Regex.Replace(strInput,"[@.,\\\/]+","").Trim

output : -
image

@sai_gupta

1 Like

can just try with this regex
image

Use an assign activity with the expression

yourString = System.Text.RegularExpressions.Regex.Replace(yourString, "[^a-zA-Z0-9\s]", "")

Explanation

Hope this clarifies

Cheers @sai_gupta

@sai_gupta

System.Text.RegularExpressions.Regex.Replace(InputStr, “[^a-zA-Z0-9\s]”, “”)

image

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