eWebProgrammer eweb  

Basic Perl   «Prev  Next»
Lesson 1

Regular expressions

Perl regex
Module introduction
Regular expressions (sometimes called regexps) are expressions used for matching patterns of text. Regexes are used for everything from simple searches to complex search-and-replace procedures. If you have used the advanced mode on any of the major Internet search engines, then you have used regular expressions.
The purpose of this module is to familiarize you with the major features of Perl's regular expressions so that you can use this feature as effectively and seamlessly as possible. This is not intended to be an exhaustive regular expression tutorial; regular expressions can be a deep subject.
Many people, upon finding that regular expressions look cryptic, decide that they are too difficult and not worth the trouble.
Once you get past that first impression, you will begin to use them more effectively and find your programs becoming smaller, faster, and more efficient.
I heartily recommend Jeffrey Friedl's book, Mastering Regular Expressions, for a detailed look into regular expressions.
Regular expressions are a language used for parsing and manipulating text. They are often used to perform complex search-and-replace operations, and to validate that text data is well-formed. Today, regular expressions are included in most programming languages and scripting languages (like JavaScript) . Furthermore regular expressions are incorporated into editors, applications, databases, and command-line tools. This book aims to give quick access to the syntax and pattern-matching operations of the most popular of these languages so that you can apply your regular-expression knowledge in any environment.