Regular Expressions in Perl
Introduction
Regular expressions (also known as "regexes", "regexps" and "re's") allow the Perl programmer to easily locate simple or somewhat more complex patterns inside a larger text, and process the text accordingly. Many beginners are intimidated by regular expressions, but they are well-worth to invest the time to learn and understand because processing text character-by-character would be slower, take more code and would not be idiomatic.
Misusing Regexes
Yet another issue is that some programmers tend to misuse regular expressions (including only one at a time) in order to do tasks for which they are not very suitable for. See our page about parsing text for some better alternatives.
Tutorials
perlretut
The built-in regular expressions tutorial in the Perl 5 distribution. Also see the following documents:
- perlrequick - Quick introduction to regular expressions.
- perlreref - Regular expression reference.
- perlre - regular expression description in Perl - not written in a very accessible way.
Modern Perl (the Book)
Modern Perl covers Regular Expressions.
Beginning Perl
Chapter 5 of "Beginning Perl" discusses regular expressions.
Perl for Perl Newbies Series
The second presentation in the series introduces regular expressions.
Resources
Awesome Regular Expressions
A public domain list of links and resources on GitHub.