Re: REGEX.Replace Question

From: Robby (edmund_at_not.my.email.com)
Date: 12/11/04


Date: Sat, 11 Dec 2004 17:17:35 +1300


Doh ... it is the third argument. Silly me.

Robby

"David" <dfoster@woofix.local.dom> wrote in message
news:slrncrkori.5gi.dfoster@woofix.local.dom...
> 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* talking about string literals. ... The second parameter ... 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: A string & a list
    ... You should exclude those elements from the string: ... The array @- is an internal one, storing the offsets of the substrings found by the last regex pattern match. ... The push of the results of the recursive call is qualified by a call to grepto make sure the new value isn't already in the list. ...
    (perl.beginners)
  • Re: simple regexp help needed - pull phrase out of string
    ... Maybe you can try this regex pattern: ... Max Williams wrote: ... and my brain hurts. ... If i have a string like this: ...
    (comp.lang.ruby)
  • Re: delete a char from string ?
    ... The first parameter is not a simple String to ... It is a Regex Pattern. ... Canadian Mind Products, Roedy Green. ...
    (comp.lang.java.help)
  • Re: regular expressions help
    ... digits, then some text, empty, one alpha character, ... I have the following Regex pattern in my code ... then 1 or 2 digits) from a longer string as long as that pattern is ...
    (microsoft.public.dotnet.languages.csharp)