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


#1

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


#2

Use replace method

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


Change comma to point
#3

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


#4

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.