Data Science Desktop Survival Guide
by Graham Williams |
|||||
Regexp Quantifiers |
Quantifier | Description | |
1 | * | The preceeding item is matched 0 or more times |
2 | + | The preceeding item is matched 1 or more times |
3 | ? | The preceeding item is matched at most 1 times. |
4 | {n} | The preceeding item is matched n times. |
5 | {n,} | The preceeding item is matched atleast n times. |
s <- c("aaab", "abb", "bc", "abbcd", "bbbc", "abab", "caa")
grep(pattern="ab*b", s, value=TRUE)
grep(pattern="abbc?", s, value=TRUE)
grep(pattern="b{2,}?", s, value=TRUE)
|