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.

New version: in addition to finding position of one character, it also finds the beginning position of a given test pattern.

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
instring("where","guess where the word where is")
# 

[Package clim.pact version 2.2-15 Index]