textclean (version 0.9.3)

match_tokens: Find Tokens that Match a Regex

Description

Given a text, find all the tokens that match a regex(es). This function is particularly useful with replace_tokens.

Usage

match_tokens(x, pattern, ignore.case = TRUE, ...)

Arguments

x

A character vector.

pattern

Character string(s) to be matched in the given character vector.

ignore.case

logical. If TRUE the case of the tokens/patterns will be ignored.

ignored.

Value

Returns a vector of tokens from a text matching a specific regex pattern.

See Also

replace_tokens

Examples

Run this code
# NOT RUN {
with(DATA, match_tokens(state, c('^li', 'ou')))

with(DATA, match_tokens(state, c('^Th', '^I'), ignore.case = TRUE))
with(DATA, match_tokens(state, c('^Th', '^I'), ignore.case = FALSE))
# }

Run the code above in your browser using DataCamp Workspace