Re: problem using Regex in a C# addin

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sijin Joseph (sijindotnet_at_hotmail.com)
Date: 04/06/04


Date: Tue, 6 Apr 2004 16:27:01 +0530

Macros in VS.Net don't use the .Net regular expressions synatx, they use the
old VS6 regular expressions syntax, look that up in the documentation. That
might be your problem

-- 
-Sijin Joseph
http://weblogs.asp.net/sjoseph
"Tom Hughes" <tom_hughes98@yahoo.com> wrote in message
news:a6e410db.0404051156.39b5a8be@posting.google.com...
> hi-
>
> i'm trying to comment out a statement in an addin using Regex with the
> following code.  in addition to the comment characters, i'm adding a
> special character so that the statements can be restored at a later
> time.  in a stand-alone program the replacement works without problem.
>  the addin code fouls the formatting for some reason.  here's the
> code...
>
>   string s, t, sPattern;
>
>   ((TextSelection) dte.ActiveDocument.Selection).SelectAll();
>   s = ((TextSelection) dte.ActiveDocument.Selection).Text;
>   sPattern = "^(?<log_statement>[ \\t]*log\\()";
>   Regex regex = new Regex( sPattern, RegexOptions.Multiline );
>   t = regex.Replace( s, "//#${log_statement}" );
>   ((TextSelection) dte.ActiveDocument.Selection).Text = t;
>
> i have compared 's' and 't' character by character and the strings
> look as they should (ie. the regex replacement appears to be working).
>  is there some encoding voodoo i need to do?  are there other ways to
> set the active document's text?
>
> thanks,
> tom


Relevant Pages

  • Re: regex, negations, grep, find and replace (a few questions)
    ... I do not know much regex. ... But it seems as if you define each character ... be aware that different tools may use slightly different syntaxes for the same regular expressions. ... expresion" might mean "matching everything not matching the regular expression" or, in other words, removing everything matching the regexp. ...
    (alt.os.linux)
  • Re: Help: How to add a character in the line
    ... I'm a Linux user, I'd like to know how to use sed or other command to add ... possible about regular expressions and the syntax of 'sed'. ... available with the regex library only on _some_ systems (while the '+' ... or even avoid the character classes which cannot be assumed on old ...
    (comp.unix.shell)
  • problem using Regex in a C# addin
    ... i'm trying to comment out a statement in an addin using Regex with the ... special character so that the statements can be restored at a later ... the addin code fouls the formatting for some reason. ... Regex regex = new Regex(sPattern, ...
    (microsoft.public.vsnet.ide)
  • Re: Search for multiple things in a string
    ... >> I also feel that Regular Expressions, being an object in asp.net (not ... So using Regex is not really like using another language (as C# is different ... I agree with you that readability is important. ... And I was not saying experiment with it. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: for a laught (???)
    ... Regex doesn't work too well with a null byte delimiter :-) ... the API for a particular form of regular expressions ... Regex doesn't work with null terminated strings. ... qualifier or the qualifier "commonly" might have suggested. ...
    (comp.lang.cobol)