Re: [R] gsub regexp question

2014-10-15 Thread Jeff Newmiller
I believe the backslash is not considered an escape character by the extended RE library used by R (perl=FALSE), so it is being treated as a literal. This means that the last ] is outside the character class and is the atom that the * applies to. gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "a]]]rra

[R] gsub regexp question

2014-10-15 Thread ALBERTO VIEIRA FERREIRA MONTEIRO
I just found a curious behaviour of regexp and I'd like to share with y'all. gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "array[n] <- 10", perl=T) # works as expected ("array[n]") gsub("^([[:alnum:]\\[\\]]*).*", "\\1", "array[n] <- 10", perl=F) # doesn't work ("a") I didn't find anything in the docum