How to replace all the occurences of a particular character in a string?

I want to replace all the ‘.’ and ‘,’ available on the string with ’ '(Space).

Use replace method

str_output = System.Text.RegularExpressions.Regex.Replace(str_input, “[.|,]”, " ")

4 Likes

Str.Replace("."," “).Replace(”,"," ")

2 Likes

Hi Ajith,

Use the Regular expression to perform the replace operation.

For Eg.
import System.Text.RegularExpressions

To replace the specific charecter
Regex.Replace(strTrg.ToString,"[.|,]","").ToString

To replce the number from string
Regex.Replace(strTrg.ToString,"[0-9]","").ToString

Regards
Vivek S.