cpos {cwhmisc}R Documentation

Find the position of a substring

Description

cpos finds the first position of a substring substring.location returns a list with starting and ending positions, works only with a single string.

Usage

cpos(str,sub,start=1)
substring.location(str, sub, restrict)

Arguments

str string (1-dim)
sub string (1-dim)
start integer
restrict vector of lower and upper index the search should be restricted to

Value

number, if found, NA otherwise. list(first,last)

Author(s)

Christian W. Hoffmann <c-w.hoffmann@sunrise.ch>
http://www.wsl.ch/personal_homepages/hoffmann/index_EN

Examples

cpos(" Baldrian","a",5) #  8
cpos("Baldrian","B",15) # NA
substring.location("In,theese,housees,there,are,rats","ees")
#$first  [1]  6 15
#$last   [1]  8 17

[Package cwhmisc version 2.0.1 Index]