Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

Examples

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))

textclean

Text Cleaning Tools

v0.9.3
GPL-2
Authors
Tyler Rinker [aut, cre], ctwheels StackOverflow [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.