match_tokens: Find Tokens that Match a Regex

Description Usage Arguments Value See Also Examples

View source: R/match_tokens.R

Description

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

Usage

1
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

1
2
3
4
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))

trinker/textmod documentation built on June 11, 2018, 3:49 a.m.