[R] Parsing regular expressions differently - feature request

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Sun Nov 9 00:37:49 CET 2008

Wacek Kusnierczyk wrote:
> Duncan Murdoch wrote:
>>>>> Here's a quick hack to achieve the impossible:
>>>> That might solve John's problem, but I doubt it.  As far as I can see
>>>> it won't handle \L, for example.
>>> well, it was not supposed to.  it addresses the need for doubling
>>> backslashes when a backslash character is an element of the regex. 
>> \L could be an element of a regex in Perl.

you should perhaps specify what you mean by 'could be an element of a
regular expression'.  there is a difference between a regular expression
and a string specifying it.

in /\LA/, i'd say the string between the slashes contains three
characters, but the regex contains just one;  there is no \L in the
regex, and no backslash either. 

in /\\LA/, i'd say the string contains four characters, but the regex
just three; there is a backslash there, but no \L.

just try qr/\L/ (that's an empty pattern), qr/\LA/ (that's a
one-character pattern equivalent to qr/a/), and qr/\\LA/. 

in a sense, \L is just a macro used in constructing regexes, but it has
no place in a regex.  in this view, "\LA" and "a" are two dstinct
strings specifying the same regex (try qr/\LA/ eq qr/a/).


More information about the R-help mailing list