Regular Expressions Todd Kelley
Regular Expressions Todd Kelley
Todd Kelley
[email protected]
2
Character classes are lists of characters inside
square brackets
The work the same in regex as they do in
globbing
Character class expressions always match
EXACTLY ONE character (unless they are
repeated by appending '*')
[azh] matches "a" or "h" or "z"
15
expressions that match zero length strings
remember that the repetition operator * means
"zero or more"
any expression consisting of zero or more of
anything can also match zero
For example, x*, "meaning zero or more x
characters", will match ANY line, up to n+1 times,
where n is the number of (non-x) characters on that
line, because there are zero x characters before and
after every non-x character
grep and regexpal.com cannot highlight matches
of zero characters, but the matches are there!
$ rm ?
postal code
A9A 9A9
[[:upper:]][[:digit]][[:upper:]] [[:digit:]][[:upper:]][[:digit:]]
postal code
A9A 9A9
Same as basic regex
[[:upper:]][[:digit]][[:upper:]] [[:digit:]][[:upper:]][[:digit:]]