How replace a special characters in string

Hi,

Im new to RPA automation. Im having requirement where I need to remove all the special character.

Ex :

I have a string called “thisIs@myQuestion#”, I want to replace all the special character and return result as “thisIsmyQuestion”

Thanks for all your help!!

Regards,
Kavya

Hi @Kavya_Bhat ,

From what i understand, you need to remove the special character from a string.

Try using Regex.

System.Text.RegularExpressions.Regex.Replace(“thisIs@myQues#”, “[^a-z A-Z]”, “”).ToString

Let me know if it works.

3 Likes

Hi!

you can get that text by using RegEx.

Please follow the bellow

1.Store the string into a variable called RegEx.
2. now use like below

System.Text.RegularExpressions.Regex.Matches(RegEx,“[^@#]”).Value

Regards,
NaNi

1 Like

Hi @THIRU_NANI ,

Thank you so much for replying so fast and helping. When I tried as told. I faced below error.

Hi @pavithra_pavi ,

Thank you so much for replying so fast. This is what I was looking for. I was able to remove the special character.

Thanks again :slight_smile: :grin:

1 Like

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