Problem with Regex.Replace( )

  • Thread starter Thread starter Ewald B.
  • Start date Start date
E

Ewald B.

Hi NG,

i want to replace the string "\i0" if the character before this is not "\".

I use the following code:

string s = @"This is not\i0 very good\\i0.";
string sReplaced = Regex.Replace(s, @"(?!\\)\\i0", "***");

Whats wrong?

Thanks :-))
 
You need a look-behind assertion, not a look-ahead one.
Use: @"(?<!\\)\\i0" as pattern.

Niki
 

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