Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string to replace specific characters

Tags:

c#

replace

For example => iddaa///news/haber05112013.jpg

Result=> iddaa/news/haber05112013.jpg

I want to replace this spesific characters ("/"); But sometimes double characters ('///') , sometimes ('//') can ı replace this? Thank you

like image 987
Ersel Bozkartal Avatar asked Oct 24 '25 06:10

Ersel Bozkartal


1 Answers

If you don't know how many repetitions there are, use Regex.Replace:

var res = Regex.Replace(orig, "/+", "/");

"/+" is a regular expression that matches one or more forward slash.

like image 54
Sergey Kalinichenko Avatar answered Oct 26 '25 19:10

Sergey Kalinichenko