How do I remove a character from specific character to specific character ...
Example
string a = " Hello ! {ssd} jksssss"; In above string i want to remove character from '{' to '}'
output -- > `Hello ! jksssss` This can be done with Regex.Replace:
string a = " Hello ! {ssd} jksssss"; string b = Regex.Replace(a, "{\w+}", ""); This won't work for "Hi {!#$#@}!", that is left as an excericse :-) Start at this MSDN page for more basic information on regular expressions in .NET.
You can use the Regex class in System.Text.RegularExpressions, to do the replace. For example:
var a = " Hello ! {ssd} jksssss"; var newString = Regex myRegex = new Regex("{{.+}}", ""); myRegex.Replace(a, ""); EDIT:
If you want to match multiple occurrances of curly braces, and replace each one, use this regular expression instead:
var a = "Hello ! {ssd} jksssss {tasdas}"; Regex myRegex = new Regex("{{[^{]+}}", ""); var newString = myRegex.Replace(a, ""); // a == "Hello ! jksssss "