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. Regards - Wolfram
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.In R you have to escape the "\". From the help page of regexpr: ## Double all 'a' or 'b's; "\" must be escaped, i.e., 'doubled' gsub("([ab])", "\\1_\\1_", "abc and ABC") HTH, Tobias -- Tobias Verbeke - Consultant Business & Decision Benelux Rue de la r?volution 8 1000 Brussels - BELGIUM +32 499 36 33 15 tobias.verbeke at businessdecision.com
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, ripley at stats.ox.ac.uk 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
EOF from a keyboard on Windows is often Ctrl+Z. But you're right; it's platform dependent. CtrlZ in Unix has less desirable effects on readLines(). And on your running R process... Drat.>>> Peter Dalgaard <P.Dalgaard at biostat.ku.dk> 29/06/2007 12:42:41 >>>S Ellison wrote:> Wouldn't it be nice if the Help for readLines mentioned how to introduce an EOF when reading from stdin ...? > > Steve E > >Yes (in a couple of other cases, too) but it is likely platform dependent. What do you use on Windows and is it the same in the terminal and the GUI versions? And on Mac? ******************************************************************* This email and any attachments are confidential. Any use, co...{{dropped}}