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
 
Back
Top