cpos {cwhstring}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, christian.hoffmann@wsl.ch, http://www.wsl.ch/staff/christian.hoffmann

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 cwhstring version 1.0.3 Index]