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:
>
> 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"                "latitude and latitude^2"   "longitude^2"
>             "longitude and longitude^2"
> > grepl("latitude^2",temp)
> [1] FALSE FALSE FALSE FALSE
>
>
> I think this must a regex problem, but I can't find out to specify the
> caret using regex.
>
> I would appreciate any help you could provide.
>
> Many thanks,
>
> Mark Na
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Tsjerk A. Wassenaar, Ph.D.

post-doctoral researcher
Biocomputing Group
Department of Biological Sciences
2500 University Drive NW
Calgary, AB T2N 1N4
Canada

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to