Monday, 19 August 2013

Replace same multiple chars with one char

Replace same multiple chars with one char

I searched for this like 30 minutes .
Found this answer .
Replace two or more chars with a char .
Here i replace two or more "-" with one "-" .
Example :
var currentUrl = currentUrl.Trim() ;
currentUrl = Regex.Replace(currentUrl, @"[/\x2D/]{2,}", "-");
where 2D is the hexa for "-" char .
You can do this for every pattern .
Convert in hexa here : http://www.string-functions.com/string-hex.aspx

No comments:

Post a Comment