[R] regexpr

From: runner <sunnyside500_at_gmail.com>
Date: Fri, 29 Jun 2007 09:37:52 -0700 (PDT)

Hi,

I 'd like to match each member of a list to a target string, e.g.



mylist=c("MN","NY","FL")
g=regexpr(mylist[1], "Those from MN:")
if (g>0)
{
"On list"
}

My question is:

How to add an end-of-string symbol '$' to the to-match string? so that 'M' won't match.

Of course, "MN$" will work, but i want to use it in a loop; "mylist[i]" is what i need. I tried "mylist[1]$", but didn't work. So why it doesn't extrapolate? How to do it?

Thanks a lot!

-- 
View this message in context: http://www.nabble.com/regexpr-tf4000743.html#a11363041
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_stat.math.ethz.ch 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.
Received on Fri 29 Jun 2007 - 16:49:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Jun 2007 - 18:32:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.