Re: REGEX.Replace Question

From: David (dfoster_at_woofix.local.dom)
Date: 12/11/04


Date: Fri, 10 Dec 2004 19:00:40 -0800

On 2004-12-11, Robby <edmund@not.my.email.com> wrote:
>
>
> It IS a bug.

No, it's not.

>
> We are not talking about string literals. We are talking about Regular
> Expression replace patterns.

Actually, we *are* talking about string literals. The second parameter
to the static Regex.Replace function is a regex pattern. But if you
look at the example again, the "\t" is in the third parameter, which is
NOT a regex pattern, it's a simple replacement string that allows only a
very few special characters, such as backreferences.

> The Regular Expression pattern "\t" is a [tab].
> So when you use "\t" in a Regular Expression replace pattern it should
> replace it with a [tab]. A Regular Expression find pattern of "\t" finds
> tabs in VB.Net.

Correct, but...

> According to pattern syntax a replace pattern of "\t"
> should insert [tab].

There's no such thing as a "replace pattern", at least not in the sense
that it's a regex pattern . What would that mean anyway? If you think
about it, you'll realize that there's no way the replacement string can
be a regex pattern.

e.g., what would you return for

        Regex.Replace("1234", "123", "\w+\t\d+")



Relevant Pages

  • Re: REGEX.Replace Question
    ... >> We are not talking about string literals. ... > to the static Regex.Replace function is a regex pattern. ... you'll realize that there's no way the replacement string can ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Strange CreateProcess() API failure.
    ... The second parameter of CreateProcess should be writable (note that it's ... declared LPTSTR as opposed to LPCTSTR). ... VC8 enforces this by putting string literals into read-only ...
    (microsoft.public.vc.language)

Loading