Re: Character Escapes Don't Work in VB Regex Replace?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 03/05/04


Date: Thu, 4 Mar 2004 23:20:11 -0600

Chris,
If you are still following this thread...

While searching for something else, I just came across RegEx.Escape and
RegEx.Unescape that will escape & unescape strings for you (including
whitespace). It may help in your efforts.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemTextRegularExpressionsRegexClassEscapeTopic.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemTextRegularExpressionsRegexClassUnescapeTopic.asp

Hope this helps
Jay

"Chris Anderson" <anonymous@discussions.microsoft.com> wrote in message
news:2AC493A6-E389-44EF-A482-9590787248D7@microsoft.com...
> Well, I figured I was hoping too much. I'd still call it a bug, though. It
actually says in the documentation for regex that all character escapes are
supported both in regular expressions and replacement patterns.
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconcharacterescapes.asp
>
> Unfortunately, it's only half true in VB. I only mention C# because I
wanted to see if this was a VB specific issue, or the .net regex engine.
Using escape characters in C# replacement patterns does work as it says in
the documentation, and as in every other language or application that
implements regex. I've been using VB for 6 years, and think .net is great,
but it's very disappointing and confusing that VB does implement the regex
behavior in a standard way. I'll probably end up writing my own fix, and
share it with anyone else who is frustrated by this.



Relevant Pages

  • Re: Character Escapes Dont Work in VB Regex Replace?
    ... >> does work as it says in the documentation, ... They do not work in that RegEx will not honor them, ... Where I am telling C# not to replace C#'s escape sequences. ... supported both in regular expressions and replacement patterns. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Regular Expression reserved letters
    ... The problem ist, that e.g.),,are reserved words in regex. ... them in filter expressions i have to escape them with \). ... If, on the other hand, you have a portion of an expresion that must be ... documentation here: <http://java.sun.com/j2se/1.4.2/docs/api/java/util/ ...
    (comp.lang.java.programmer)
  • Re: Confusion about String.matches method
    ... If you wanted a regex you want the two chars \ and n in the regex ... string. ... However, if you do that, Java will think \ is an escape char, so you ... How long did it take after the car was invented before owners understood ...
    (comp.lang.java.programmer)
  • Re: Character Escapes Dont Work in VB Regex Replace?
    ... VB.NET just does not support C# escape sequences, ... not the replace string according to the Character Escapes section of Regular ... as the RegEx class itself is defining this behavior. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Control characters - regex to match/lose these?
    ... The is causing the RE to match 'escape, ... by (either a multi-char escape sequence or one of the single-char ... understand, that regex. ... any number of times (though not necessarily the same char) but only if ...
    (comp.lang.perl.misc)