String split

hello guys
i have a string
SPIRIT,LAKE,IA,51360
i need to write this string as
SPIRIT LAKE,IA,51360
how can i do
pls help
as i dont want comma between spirit lake
Regards Arjun

Hi @arjun27

Try this

var regex = new Regex(Regex.Escape(","));

var newText = regex.Replace("SPIRIT,LAKE,IA,51360", " ", 1);

Thanks,
Prankur

2 Likes

ReplaceFirstOccurenceOfComma.xaml (5.8 KB)

Try this. No regex has been used.

1 Like

Hey @arjun27

You can go with @PrankurJoshi one.

but you want simple and short you can go with this:-

String  Str = SPIRIT,LAKE,IA,51360

String Final_Str = Str.Remove(Str.IndexOf(","c),1).Insert(Str.IndexOf(","c)," ")
 
   // Output:- SPIRIT LAKE,IA,51360

Regards…!!
Aksh
Regards…!!
Aksh

“PRINCETON, NJ 08540-6819”
this is string
“PRINCETON,NJ,08540-6819”

so i will get problem in such if i handle that

spirit late is city name with 2 words
there are city with one name too