Re: REGEX.Replace Question
From: Whitless (Whitless_at_discussions.microsoft.com)
Date: 12/13/04
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: VB Windows Service"
- Previous message: Terry Olsen: "Re: What's the best way to make a Terminal window?"
- In reply to: David: "Re: REGEX.Replace Question"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 13 Dec 2004 07:11:01 -0800
What I don't get though is (as my original post highlighted) I could pass the
third argument "\t" in C# and it would return a tab. I realise that there
would not be much need for a regex replace pattern, however it can be done in
C# for my example. Why?
"David" wrote:
> 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+")
>
>
>
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: VB Windows Service"
- Previous message: Terry Olsen: "Re: What's the best way to make a Terminal window?"
- In reply to: David: "Re: REGEX.Replace Question"
- Messages sorted by: [ date ] [ thread ]