regex - C# \b not being found -


        match m = regex.match(richtext, "\\\\par\b", regexoptions.none);         richtext = regex.replace(richtext, "\\\\par\b", "", regexoptions.ignorecase); 

input:

"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil arial;}{\\f1\\fnil\\fcharset0 microsoft sans serif;}}\\viewkind4\\uc1\\pard\\f0\\fs20 cc: not specified\\f1\\fs17\\par}" 

i'd find \\par only, , not \\pard can found in middle of input.

mrab correct:

[testclass] public class unittest1 {     [testmethod]     public void testwithdoublebackslash()     {         const string regex1 = "\\\\par\\b";         testregex(regex1);     }      [testmethod]     public void testwithsinglebackslash()     {         const string regex2 = "\\\\par\b";         testregex(regex2);     }      private static void testregex(string regex)     {         var richtext =             "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil arial;}{\\f1\\fnil\\fcharset0 microsoft sans serif;}}\\viewkind4\\uc1\\pard\\f0\\fs20 cc: not specified\\f1\\fs17\\par}";         match m = regex.match(richtext, regex, regexoptions.none);         var output = regex.replace(richtext, regex, "", regexoptions.ignorecase);          console.writeline("before : [" + richtext + "]");         console.writeline("after  : [" + output + "]");          assert.istrue(output.contains("pard"));         assert.isfalse(output.contains("fs17\\par"));     } } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -