On Thu, 28 Jun 2007, Wolfram Fischer wrote:

> What's really the problem with:
>
>> regexpr( '\.odt$', "xxxxYodt", perl=TRUE )
>       Warning: '\.' is an unrecognized escape in a character string
>       Warning: unrecognized escape removed from "\.odt$"
>       [1] 5
>       attr(,"match.length")
>       [1] 4
>
> I know that I could use:
>> regexpr( '[.]odt$', "xxxxYodt", perl=TRUE )
>
> But it seems to me that the first expression is also
> an accepted regular expression in accordance with perl.

This is explained in ?regexp (in the See Also of ?regexpr):

      Patterns are described here as they would be printed by 'cat': _do
      remember that backslashes need to be doubled when entering R
      character strings from the keyboard_.

and in the R FAQ and ....

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to