[R] Backslash

Josef Eschgfaeller esg at felix.unife.it
Mon May 23 11:46:09 CEST 2005


Why sometimes one has to put a double
backslash in regular expressions, but
often simple backslashes work too?
Is only a \ required for giving a
metacharacter its usual meaning?
---------------------------------------
u=grep('\\{[\\-u]x',a,perl=T)

       # equivalent to

u=grep('\{[\-u]x',a,perl=T)

       # but

u=grep('\w',a,perl=T)

       # is not correct and requires

u=grep('\\w',a,perl=T)
---------------------------------------
Josef Eschgfäller

-- 
Josef Eschgfäller
Dipartimento Matematico
Universita' di Ferrara
http://felix.unife.it


More information about the R-help mailing list