Introduction

Regualr expressions are a powerful tool for matcing patterns and manipulating text. While not as fast as string matching, they are flexible. They allow you to construct patterns to match almost any conceivable combination of characters with a simple gramamr.

Regular expressions are handy when transforming plain text into HTML and vice versa. PHP has many built-in functions to handle these tasks. PHP offers 2 sets of regular expression functions. The first set include the traditional (or POSIX) fucntions, whose names each begin with ereg (for "extended" regular expressions). The other set includes the Perl-compatible family of functions, prefaced with preg (for Perl-compatible regular expressions). The ereg functions are slower than the preg functions. So there's no longer any reason to use the ereg functions.

You can check the regular expressions library at http://regexlib.com


Regular Expressions | Introduction | Matching a Pattern | Metacharacters | Quantifiers | Character Classes | Pattern Modifiers | Matching and Replacing Patterns | Splitting Strings | Finding Elements of an Array | Finding the nth Occurence of a Match | Choosing Greedy or Nongreedy matches
© 2008: Hann So
email: hso@voyager.deanza.edu