[R] regex pattern assistance
smartpink111 at yahoo.com
Fri Aug 15 20:37:23 CEST 2014
You could try:
On Friday, August 15, 2014 12:20 PM, Tom Wright <tom at maladmin.com> wrote:
Can anyone please assist.
given the string
> x<-"/mnt/AO/AO Data/S01-012/120824/"
I would like to extract "S01-012"
> str_match(x,"\\/mnt\\/AO\\/AO Data\\/(.+)\\/+")
> str_match(x,"\\/mnt\\/AO\\/AO Data\\/(\\w+)\\/+")
both nearly work. I expected I would use something like:
> str_match(x,"\\/mnt\\/AO\\/AO Data\\/([\\w -]+)\\/+")
but I don't seem able to get the square bracket grouping to work
correctly. Can someone please show me where I am going wrong?
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help