RegEx trouble - need help matching a string
Hi there,
I am passing a selected area of text as a string (from an IDE text editor) and attempting to match it against a textfile using the following regex :
Regex targetExpOld = new Regex(@"^\s+"+content+ @"\s+$", RegexOptions.Multiline);
if content = "int i = 6;" i get a match
however if content contains a "." or a "(" it doesnt find a match
any idea how i can dodge this - i realise its a problem with special characters but I'm new to regex and dont have time to become an expert!(just yet)
kind regards
Tom
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
onez74 pointsPosted Apr 25, 2006, 5:19 PM EDT
string str = Regex.Escape("sdfsd(sdf{sdf*");
becomes "sdfsd\(sdf\{ etc.