6.11 Regexp Quantifiers

20180608 Quantifiers are used to match repitition of a pattern within a string. The following table shows a list of quantifiers.

% latex table generated in R 4.4.1 by xtable 1.8-4 package % Sat Oct 26 20:45:10 2024

Some examples will illustrate.

s <- c("aaab", "abb", "bc", "abbcd", "bbbc", "abab", "caa")
grep(pattern="ab*b", s, value=TRUE)
## [1] "aaab"  "abb"   "abbcd" "abab"
grep(pattern="abbc?", s, value=TRUE)
## [1] "abb"   "abbcd"
grep(pattern="b{2,}?", s, value=TRUE)
## [1] "abb"   "abbcd" "bbbc"


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0