expressions are a minilanguage used to describe patterns of strings.
A regular expression literal is a pattern between slashes or between
arbitrary delimiters followed by
/pattern/ /pattern/im # option can be specified %r!/usr/local! # general delimited regular expression
Regular expressions have their own power and mystery; for more on this topic, see O’Reilly’s Mastering Regular Expressions by Jeffrey E.F. Friedl.
Regular expression literals may include an optional modifier to control various aspects of matching. The modifier is specified after the second slash character, as shown previously and may be represented by one of these characters:
Substitutes only once
Ignores whitespace and allows comments in regular expressions
Matches multiple lines, recognizing newlines as normal characters
Except for control characters,
\), all characters match
themselves. You can escape a control character by preceding it with a
Regular characters that express
}) can match very long
strings, but when you follow such characters with control characters
?, you invoke a nongreedy match that finishes at
the first successful match (i.e.,
*, etc.) followed by
Matches beginning of line.
Matches end of line.
Matches any single character except newline. Using
moption allows it to match newline as well.
Matches any ...