Hi,
I want to take a string, and strip all non-alphanumeric characters from it using regex.replace.
I am a little confused using the construct, specifically what the 3 parameter of Regex.Replace, <a target="_new" href="http://msdn2.microsoft.com/en-us/library/taz3ak2f(VS.80).aspx">string replacement</a>.
So my regex looks like:
string regex = @"^[a-zA-Z0-9]*$";
string input = "just testing-my regex@?#2~Rasf.:";
// not sure about my 3rd parameter $1 ????
string output = Regex.Replace(input, regex, "$1", RegexOptions.Compiled | RegexOptions.IgnoreCase);
This code doesn't seem to work, can someone help me out?

1 answers
Ok I obviously can't read hehe, string replacement is the replacement text, in this case I want a empty string "".
The regular expression works just fine now...sheesh!
answered 2 years ago by:
0
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!