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.
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)
|
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. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.