Re: [R] locate substring in the string it belong to

2009-07-20 Thread Scott Sherrill-Mix
Not sure it's exactly what you want but you could use gregexpr. If you're worried about your search string starting within your search string (like your example) then maybe you could find one match at a time, mask it out with gsub, and loop until you don't have any more matches: search<-'cc' mask

[R] locate substring in the string it belong to

2009-07-20 Thread kevinchang
Hi R users, I am trying generate the indices for locating a in the string it come from. Given the length of the string, it will take too long using the combn() for further comparison. I am wondering if R has any built-in function for this purpose. To make it concrete: this.substring="cc" this