4. Example
• Try match aab
• First two a and follow one b
• Accept
• aaaaaabbbbb
• aab
• Reject
• ab
• abb
a
a
bb
5. Grammar I
• . Any character except NEWLINE
• a The character a
• Escapes a special character
• a b f n r t v 0
• YYY
• xXX
6. Grammar II
• a | b The pattern a or pattern b
• a{x, y} x to y number of a
• [abc] One character of a, b or c
• a* Zero or more a
• a+ One or more a
• a? Zero or one a
• reluctant a*? a+?
• greedy a.+
7. Grammar III
• 0-9 Digit from 0 to 9
• d Digit (0 -9)
• D Not digit
• s One whitespace
• S Not whitespace
8. Grammar IV
• (…) Group of pattern
• (?: …) Not-capture group
• (?>…) Atomic group
• (?|…) Duplicate group
• (?P<name>…) Named a group
• (?P=name) Backreference to named group