Chapter 14. Managing Regular Expressions


Today almost every high-level programming language provides tools for working with patterns and retrieving complex sequences of characters. Usually pattern matching is performed by using so-called regular expressions. In PHP, a library for handling regular expressions is provided. With the help of this library, it is possible to develop a completely new view of the data and to solve complex operations efficiently.

Regular expressions are essential, especially if you have to search for imprecise data. In some cases, you might not know exactly what you are looking for. Imagine a table for storing products. Somebody asks you to look for the product, but the only thing he knows about the product is that the product id starts with "5" and ends with "98." With the help of a simple regular expression, it is an easy task to find the appropriate product with just one line of code. With the propagation of Perl, regular expressions became more and more popular. Nowadays almost every high-level programming language available on Unix machines is capable of handling regular expressions that allow you to build powerful applications fast, easily, and reliably. When you are familiar with regular expressions, you don't want to live without them.

Depending on the software you are planning to use, the syntax and the meaning of a regular expression will vary. Every software package has a slightly different flavor of regular expressions, and this can make things confusing. In this chapter you will deal with regular expressions for PHP and SQL. Both PHP and SQL have strong capabilities for pattern matching and can be used efficiently. However, some major differences have to be taken into consideration.



PHP and PostgreSQL. Advanced Web Programming2002
PHP and PostgreSQL. Advanced Web Programming2002
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 201

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net