Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-18 Thread Upton, Stephen (Steve) (CIV)
esearch Department Naval Postgraduate School SEED Center web site: http://harvest.nps.edu -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Berend Hasselman Sent: Friday, September 18, 2015 1:30 AM To: Dimitri Liakhovitski Cc: r-help Subject: Re: [R] Hep w

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-18 Thread Dimitri Liakhovitski
web site: http://harvest.nps.edu > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Berend > Hasselman > Sent: Friday, September 18, 2015 1:30 AM > To: Dimitri Liakhovitski > Cc: r-help > Subject: Re: [R] Hep with regex! - combina

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Dimitri Liakhovitski
For the last one, looks like this one works: x[grep("^(q10|q12).*\\_1$", x)] On Thu, Sep 17, 2015 at 5:46 PM, Dimitri Liakhovitski wrote: > Duncan, > Of course my verbal descriptions and my code don't match my regexp - > otherwise I wouldn't be asking the

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Duncan Murdoch
On 17/09/2015 5:11 PM, Dimitri Liakhovitski wrote: > (x <- c("q10_1", "q10_2", "q10_11", "q12_1", "q12_2", "q13_1", "q13_11")) > > # Which strings start with "q10" or "q12? - WORKS > x[grep("^q10|q12", x)] > > # Which strings end with "1"? - WORKS > x[grep("1$", x)] > > # Which strings end with

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread David Winsemius
On Sep 17, 2015, at 2:11 PM, Dimitri Liakhovitski wrote: > (x <- c("q10_1", "q10_2", "q10_11", "q12_1", "q12_2", "q13_1", "q13_11")) > > # Which strings start with "q10" or "q12? - WORKS > x[grep("^q10|q12", x)] > > # Which strings end with "1"? - WORKS > x[grep("1$", x)] > > # Which strings

[R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Dimitri Liakhovitski
(x <- c("q10_1", "q10_2", "q10_11", "q12_1", "q12_2", "q13_1", "q13_11")) # Which strings start with "q10" or "q12? - WORKS x[grep("^q10|q12", x)] # Which strings end with "1"? - WORKS x[grep("1$", x)] # Which strings end with "_1"? - WORKS x[grep("\\_1$", x)] # Which strings start with "q10"

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Dimitri Liakhovitski
Duncan, Of course my verbal descriptions and my code don't match my regexp - otherwise I wouldn't be asking the question, would I? Please assume my verbal descriptions are correctly describing what I want. Thank you! On Thu, Sep 17, 2015 at 5:42 PM, Duncan Murdoch

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Duncan Murdoch
On 17/09/2015 5:46 PM, Dimitri Liakhovitski wrote: > Duncan, > Of course my verbal descriptions and my code don't match my regexp - > otherwise I wouldn't be asking the question, would I? > Please assume my verbal descriptions are correctly describing what I want. Sorry, I interpreted "works" and

Re: [R] Hep with regex! - combination of ^, |, \\, _ and $

2015-09-17 Thread Berend Hasselman
> On 17 Sep 2015, at 23:11, Dimitri Liakhovitski > wrote: > > (x <- c("q10_1", "q10_2", "q10_11", "q12_1", "q12_2", "q13_1", "q13_11")) > > # Which strings start with "q10" or "q12? - WORKS > x[grep("^q10|q12", x)] > > # Which strings end with "1"? - WORKS >