Skip to content
Back to formatted view

Raw Message

Message-ID: <1408121781.2063.25.camel@tom-laptop>
Date: 2014-08-15T16:56:21Z
From: Tom
Subject: regex pattern assistance
In-Reply-To: <1408119535.2063.16.camel@tom-laptop>

WOW!!!

What can I say 4 answers in less than 4 minutes. Thank you everyone. If
I can't make it work now I don't deserve to. 

btw. the strsplit approach wouldn't work for me as:
a) I wanted to play with regex and 
b) the location isn't consistent.

Nice to see email support still works, not everything has moved to
linkedin and stackoverflow.


Thanks again,
Tom


On Fri, 2014-08-15 at 12:18 -0400, Tom Wright wrote:
> Hi,
> Can anyone please assist.
> 
> given the string 
> 
> > x<-"/mnt/AO/AO Data/S01-012/120824/"
> 
> I would like to extract "S01-012"
> 
> require(stringr)
> > 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?
> 
> Thanks,
> Tom
>