Regular Expression | Set |
---|---|
a | { a } |
b | { b } |
ab -- sequence | { ab } |
c | d -- choice | { c, d } |
a (b | c) | { ab, ac } |
a5 -- repetition | { aaaaa } |
a* | { ε, a, aa, aaa, aaaa, aaaaa, aaaaaa, ... } |
More examples:
cd web/3800/notes egrep '(S|s)(Y|y)(N|n)(T|t)(A|a)(X|x)' *.htmlor at the Windows Command prompt (with GOW installed):
c: cd web\3800\notes egrep "(S|s)(Y|y)(N|n)(T|t)(A|a)(X|x)" *.htmlMatches Syntax, SYNTAX, sYntax, etc.
(+|-|ε)(0|1)(0|1)*
if input != a error advance if input != b error advance
while input == a advance
if input == a or input == b advance else error
while input == 0 advance if input != 1 error advance while input == 0 or input == 1 advance
egrep \[[0-9a-zA-Z_]*\] *.cpp
[^[^x]]
, only the outer brackets and the first ^ and ] have special
meaning; this RE is incorrect because it has too many closing brackets,
and if you delete the last character you get the same as [^x[^]
which would mean all but the x, circumflex, and left bracket.
VARIABLE: regular expression ;
SALUTATION: 'Hello';
SALUTATION: 'Hello' | 'Hi' | 'Greetings,';
ANY: .;
DIGIT: '0'..'9'; LETTER: ('A'..'Z') | ('a'..'z');
IDENTIFIER_CHARACTER: ('a'..'z') | ('A'..'Z') | ('0'..'9') | '_';
NUMBER: ('0'..'9')+; ID: ('a'..'z')+('0'..'9')*;
MONTH: '1'?('0'..'9');
NON_DIGIT: ~('0'..'9');