Main Navigation

Content

Regular Expressions in Perl

Learn Perl Now!
And get a job doing 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:

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.

Share/Bookmark

Sidebar

Footer