Regexp.Replace Problem

  • Thread starter Thread starter KennethSoona
  • Start date Start date
K

KennethSoona

content=Regex.Replace(content, @"/*Offline*/", @"//Offline");
content=Regex.Replace(content, @"//Online", @"/*Online*/");

Second line works fine but the first didn't!
I think the problem are the "*" in the first line.
Is it a bug?
 
KennethSoona said:
content=Regex.Replace(content, @"/*Offline*/", @"//Offline");
content=Regex.Replace(content, @"//Online", @"/*Online*/");

Second line works fine but the first didn't!
I think the problem are the "*" in the first line.
Yup.

Is it a bug?

Yes, but in your code rather than the regex code :) It's because * is a
special character in regular expressions. Try:

content=Regex.Replace(content, @"/\*Offline\*/", "//Offline");
 
Back
Top