reagan123 Posted October 26, 2005 Posted October 26, 2005 i know i can use string.replace to find a character and then replace it with another... what if i want to find 2 characters? what is the best thing to use? can this be done with one string.replace() or two of them (one for each character) or is there a better way? i want to be able to remove '&' or '=' from a string. thanks for the insight. //Gets rid of '&' character string test = "This & That"; test=test.Replace("&", " "); Console.WriteLine(test); Quote
Leaders dynamic_sysop Posted October 26, 2005 Leaders Posted October 26, 2005 use System.Text.RegularExpressions.Regex ie: [Csharp] string s = "test with = & the & sign = no good, we must remove the = & the & :)"; System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex("([&])|([=])"); s = rgx.Replace(s," "); Console.WriteLine(s); [/csharp] Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.