bracketedStrings: Extract bracketed substrings.

Description Usage Arguments Value Author(s) See Also Examples

Description

Extract substrings that are bracketed by specified strings before and after.

Usage

1
bracketedStrings(s, before, after, verbose=FALSE, addNames=FALSE, drop.na=TRUE, warn.if.gt.1=TRUE)

Arguments

s

Vector of strings to search.

before

String to the left of the desired substring within s.

after

String to the right of the desired substring within s.

verbose

If TRUE, print the starting and ending index (or indices) of the desired substring(s).

addNames

If TRUE, and if s is a vector, set the names attribute of the return value to s.

drop.na

If TRUE, remove empty strings from the return value.

warn.if.gt.1

If TRUE, warn if a string has more than one pair of bracketed target strings.

Value

For a single input string s, the return value is the desired substring sandwiched between before and after. For a vector of inputs, list of outputs.

Author(s)

Roger Day

See Also

DAVIDQuery

Examples

1
2
3
4
5
 
bracketedStrings("quickbrownfox", "quick", "fox")
bracketedStrings(c("quickbrownfox", "quickredfox"), "quick", "fox", addNames=TRUE)
bracketedStrings("quickbrownfoxANDquickredfox", "quick", "fox")
bracketedStrings("quickbrownfoxANDquickredfox", "quick", "fox", warn.if.gt.1=FALSE)

DAVIDQuery documentation built on Sept. 12, 2016, 6:11 a.m.