[R] regular expression help

C Lin baccts at hotmail.com
Fri Jun 27 02:05:26 CEST 2014


Dear R users,

I need to match a string. It can be followed or preceded by whitespace or // or nothing.
How do I code it in R?

For example:
test <- c('AARSD11','AARSD1-','AARSD1//','AARSD1 //','//AARSD1');
grep('AARSD1(\\s*//*)',test);

should return 3,4,5 and 6.

Thanks in advance for your help.

Lin 		 	   		  


More information about the R-help mailing list