Re: [R] Regular Expression returning unexpected results

2013-10-29 Thread Lopez, Dan
3 11:08 AM To: Lopez, Dan; R help (r-help@r-project.org) Subject: Re: [R] Regular Expression returning unexpected results Please read and follow the Posting Guide, in particular re plain text email. You need to keep in mind that the characters in literal strings in R source have to make it into

Re: [R] Regular Expression returning unexpected results

2013-10-29 Thread David Carlson
Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lopez, Dan Sent: Tuesday, October 29, 2013 12:13 PM To: R help (r-help@r-project.org) Subject: [R] Regular

Re: [R] Regular Expression returning unexpected results

2013-10-29 Thread Jeff Newmiller
Please read and follow the Posting Guide, in particular re plain text email. You need to keep in mind that the characters in literal strings in R source have to make it into RAM before the regex code can parse it. Since regex needs a single backslash to escape normal parsing and interpret 1 as a

Re: [R] Regular Expression returning unexpected results

2013-10-29 Thread Sarah Goslee
On Tue, Oct 29, 2013 at 1:13 PM, Lopez, Dan wrote: > grep("^([a-z]+) +\1 +[a-z]+ [0-9]",lines) Your expression has a typo: R> grep("^([a-z]+) +\\1 +[a-z]+ [0-9]",lines) [1] 2 -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.or

[R] Regular Expression returning unexpected results

2013-10-29 Thread Lopez, Dan
Hi, So I just took an intro to R programming class and one of the lectures was on Regular Expressions. I've been playing around with various R functions that use Regular Expressions. But this has me stumped. This was part of a quiz and I got it right through understanding the syntax. But when I