Node:Regular Expression Shortcuts,
Regular Expression Shortcuts
Writing out regular expressions can be problematic. For example, if we want
to have a regular expression that matches all digits, we have to write:
It would be terribly annoying to have to write such things out. So, Perl
gives an incredible number of shortcuts for writing regular expressions.
These are largely syntactic sugar, since we could write out regular
expressions in the same way we did above. However, that is too cumbersome.
For example, for ranges of values, we can use the brackets,
So, for our digit expression above, we can write
[0-9]. In fact,
it is even easier in perl, because
\d will match that very same
There are lots of these kinds of shortcuts. They are listed in the
perlre online manual. They are listed in many places, so there
is no need to list them again here.
However, as you learn about all the regular expression shortcuts,
remember that they can all be reduced to the original operators we
discussed above. They are simply short ways of saying things that can
be built with regular characters,