instring {clim.pact} | R Documentation |
Finds the position of a character in a string (character vector). Similar to regexpr(), but a test with regexpr() failed with some characters. instring() returns all position with a character match, whereas regexpr() only returns the first position for a pattern match.
New version: in addition to finding position of one character, it also finds the beginning position of a given test pattern.
instring(c,target,case.match=TRUE)
c |
Character to look for. |
target |
string to search. |
case.match |
FALSE -> not case sensitive. |
vector of intigers.
R.E. Benestad
instring("e","efile.dat") # 1 5 regexpr("e","efile.dat") #[1] 1 #attr(,"match.length") #[1] 1 # Case when regexpr() doesn't give the desired result: regexpr(".","file.name") #[1] 1 #attr(,"match.length") #[1] 1 instring(".","file.name") #[1] 5 instring("where","guess where the word where is") #