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");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top