
Thank you. I know grep, but I don't know how to use it for what I need to do. 
for instance: 
> grep("bcd", "abcd")
returns:
[1] 1
> grep("bcd", "aabcd")
returns:
[1] 1

I need the first one to return 2 ("b" is in the 2nd cell), and the second one return 3 ("b" is in the 3rd cell).

thanks

> From: nick.sabbe@ugent.be
> To: ybaranan@hotmail.com; r-help@r-project.org
> Subject: RE: [R] Find index of a string inside a string?
> Date: Mon, 25 Oct 2010 13:42:23 +0200
> 
> For simple searches, use grep with fixed=TRUE.
> Check ?grep.
> 
> 
> Nick Sabbe
> --
> ping: nick.sabbe@ugent.be
> link: http://biomath.ugent.be
> wink: A1.056, Coupure Links 653, 9000 Gent
> ring: 09/264.59.36
> 
> -- Do Not Disapprove
> 
> 
> 
> 
> -----Original Message-----
> From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org] On
> Behalf Of yoav baranan
> Sent: maandag 25 oktober 2010 13:27
> To: r-help@r-project.org
> Subject: [R] Find index of a string inside a string?
> 
> 
> Hi, 
> I am searching for the equivalent of the function Index from SAS. 
> 
> In SAS: index("abcd", "bcd") will return 2 because bcd is located in the 2nd
> cell of the abcd string. 
> The equivalent in R should do this:
> > myIndex <- foo("abcd", "bcd") #return 2. 
> What is the function that I am looking for?
> 
> I want to use the return value in substr, like I do in SAS.
> 
> thanks, y. baranan.
>  		 	   		  
> 	[[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.
> 
 		 	   		  
	[[alternative HTML version deleted]]

