[R] help with regexps

Dieter Menne dieter.menne at menne-biomed.de
Wed Oct 7 14:34:00 CEST 2009




Luca Braglia-2 wrote:
> 
> I'd like to match exactly numbers from 1 to 27.
> 

If you feel in masochistic mode, you can do it:

b = c("32","3","17","27","28","57","a13")
a = c("^([0-9]|[0-1][0-9]|2[0-7])$")

grep(a,b,value=TRUE)

A much more flexible way would be to isolate the numeric part first, and
test for the range in a seconde step.

Dieter


-- 
View this message in context: http://www.nabble.com/help-with-regexps-tp25783202p25783948.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list