Copyright © 2024 SingChun Lee Bucknell University. All rights reserved. Sites developed using revealjs.
Idea | Regex Example | Matched Strings |
---|---|---|
or | a|b | "a", "b" |
concatenation | ab | "ab" |
repetition | a* | "", "a", "aa", "aaa", ... |
Idea | Regex Example | Matched Strings |
---|---|---|
grouping () | (ab)|(cd) | "ab", "cd" |
one or more | a+ | "a", "aa", "aaa", ... |
zero or one | a? | "", "a" |
anything excepts newline | . | "A", " ", "3", "$", ... |
empty string (in formal definition: ε) | ^$ | "" |
set | [azAZ12] | "a", "z", "A", "Z", "1", "2" |
range | [a-zA-Z0-9] | "B", "u", "4", ... |
not | [^a] | "B", "b", "3", "$", ... |
reserved/escaped | \+; \*; \d | "+"; "*"; "0", "1", ..., "9" |
Idea | Regex Example | Matched Strings |
---|---|---|
how many | a{3} | "aaa" |
range of repetition | a{3,5} | "aaa", "aaaa", "aaaaa" |