Re: [R] Regex for ^ (the caret symbol)?

2013-01-22 Thread S Ellison
-Original Message- So what is the special behavior of the ^ symbol when not at the beginning of the string that occurs when it is not escaped? I think it retains its meaning as an assertion that it occurs at the beginning of the line, and so a pattern like a^b could never

[R] Regex for ^ (the caret symbol)?

2013-01-21 Thread mtb954
Hello R-helpers, I am trying to search for string that includes the caret symbol, using the following code: grepl(latitude^2,temp) And R doesn't like that. It gives me: temp-c(latitude^2,latitude and latitude^2,longitude^2,longitude and longitude^2) temp [1] latitude^2

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Tsjerk Wassenaar
Hi Mark Na, Try: grepl(latitude\\^2,temp) ^ is a control character for negation, so you have to escape it. Cheers, Tsjerk On Mon, Jan 21, 2013 at 4:26 PM, mtb...@gmail.com wrote: Hello R-helpers, I am trying to search for string that includes the caret symbol, using the following code:

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Tsjerk Wassenaar
Oh, I'm jetlagged. ^ is a control character for 'start of string'. In the context of a character set it means negation: [^a-z]. Ciao, Tsjerk On Mon, Jan 21, 2013 at 4:33 PM, Tsjerk Wassenaar tsje...@gmail.com wrote: Hi Mark Na, Try: grepl(latitude\\^2,temp) ^ is a control character for

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread mtb954
Hi Tsjerk, many thanks...that worked perfectly! Mark Na On Mon, Jan 21, 2013 at 9:36 AM, Tsjerk Wassenaar tsje...@gmail.com wrote: Oh, I'm jetlagged. ^ is a control character for 'start of string'. In the context of a character set it means negation: [^a-z]. Ciao, Tsjerk On Mon, Jan

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Jeff Newmiller
I am not sure I understand what worked perfectly, since it is my understanding that ^ is only special at the beginning of the regex (to anchor the pattern at the beginning of the target string) or as the first character of a character set (to indicate exclusion of the listed characters). In any

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Rich Shepard
On Mon, 21 Jan 2013, mtb...@gmail.com wrote: I am trying to search for string that includes the caret symbol, using the following code: grepl(latitude^2,temp) Many regex implementations require us to escape a metacharacter such as '^' by preceeding it with a backslash. This indicates the

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Duncan Murdoch
On 13-01-21 11:48 AM, Jeff Newmiller wrote: I am not sure I understand what worked perfectly, since it is my understanding that ^ is only special at the beginning of the regex (to anchor the pattern at the beginning of the target string) or as the first character of a character set (to

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Jeff Newmiller
So what is the special behavior of the ^ symbol when not at the beginning of the string that occurs when it is not escaped? --- Jeff NewmillerThe . . Go Live...

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread David Winsemius
On Jan 21, 2013, at 10:05 AM, Jeff Newmiller wrote: So what is the special behavior of the ^ symbol when not at the beginning of the string that occurs when it is not escaped? Isn't there a distinction between what _is_ special and what should be special. You are saying that ^ after the

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Duncan Murdoch
On 13-01-21 1:05 PM, Jeff Newmiller wrote: So what is the special behavior of the ^ symbol when not at the beginning of the string that occurs when it is not escaped? I think it retains its meaning as an assertion that it occurs at the beginning of the line, and so a pattern like a^b could

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Jeff Newmiller
Apparently Extended RegExp syntax eliminated the ^-is-an-ordinary-character-except-for-two-uses meaning that I am familiar with from the Basic RegExp usage, since GNU grep with the -e option also refuses to match the carat unless it is escaped. The TRE library treats BRE as obsolete, so we

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Duncan Murdoch
On 13-01-21 3:20 PM, Jeff Newmiller wrote: Apparently Extended RegExp syntax eliminated the ^-is-an-ordinary-character-except-for-two-uses meaning that I am familiar with from the Basic RegExp usage, since GNU grep with the -e option also refuses to match the carat unless it is escaped. The

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread Rui Barradas
Hello, Em 21-01-2013 20:52, Duncan Murdoch escreveu: On 13-01-21 3:20 PM, Jeff Newmiller wrote: Apparently Extended RegExp syntax eliminated the ^-is-an-ordinary-character-except-for-two-uses meaning that I am familiar with from the Basic RegExp usage, since GNU grep with the -e option also