Skip to contents

Find the number and position of terms matching a given term in a given text.

Usage

find_matches_and_positions(term, text, ignore.case = TRUE)

Arguments

term

A string representing the term to be matched.

text

A string representing the text to check for matches.

Value

A named list with the following elements:

count

Integer, the number of matches.

first_ix

Integer, the position of the first match.

See also

Other report-dev: download_webpage_txt(), prep_term_list()

Examples

text <- "This is a sample text with several sample words."
term <- "sample"
find_matches_and_positions(term = term, text = text)
#> $count
#> [1] 2
#> 
#> $positions
#> [1] 11 36
#>