instring {clim.pact}R Documentation

instring

Description

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.

Usage

instring(c,target,case.match=TRUE)

Arguments

c Character to look for.
target string to search.
case.match FALSE -> not case sensitive.

Value

vector of intigers.

Author(s)

R.E. Benestad

Examples

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

[Package Contents]