Learn R Programming

DAVIDQuery (version 1.32.0)

bracketedStrings: Extract bracketed substrings.

Description

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

Usage

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.

See Also

DAVIDQuery

Examples

Run this code
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)

Run the code above in your browser using DataLab