regex: Regular expression usage with sensible defaults

Description Usage Arguments

Description

you want regular expressions to be accurate and fast. This usually translates to either (perl=TRUE, useBytes=TRUE, ignore.case=TRUE) or just fixed=TRUE. Why bother having to type those in every time?

Also, let's be honest, gsub is normally used to get rid of substrings you don't want, with replacement = "" - so let's have a function that just does that.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fast_grepl(x, pattern, ignore_case = TRUE)

fixed_grepl(x, pattern)

fast_remove(x, pattern, ignore_case = TRUE)

fixed_remove(x, pattern, ignore_case = TRUE)

fast_substitute(x, pattern, replacement, ignore_case = TRUE)

fixed_substitute(x, pattern, replacement)

Arguments

x

the vector to run the regex over looking for matches

pattern

the regular expression to use.

ignore_case

whether to ignore the casing of x when comparing to the pattern or not.

replacement

a string to replace matches with.


Ironholds/olivr documentation built on May 7, 2019, 6:40 a.m.