Lesson 1. Introducing Regular Expressions

In this lesson you’ll learn what regular expressions are and what they can do for you.

Understanding the Need

Regular expressions (or regex, for short) are tools, and like all tools, regular expressions are designed to solve a very specific problem. The best way to understand regular expressions and what they do is to understand the problem they solve.

Consider the following scenarios:

• You are searching for a file containing the text car (regardless of case) but do not want to also locate car in the middle of a word (for example, scar, carry, and incarcerate).

• You are generating a Web page dynamically (using an application server) and need to display text retrieved from a database. Text may contain ...

Get Sams Teach Yourself Regular Expressions in 10 Minutes now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.