Skip to main content


developerWorks  >  Open source  >

How to use regular expressions in PHP

developerWorks

Level: Intermediate

Nathan A. Good (mail@nathanagood.com), Author and Software Engineer, Alliance of Computer Professionals

10 Jan 2006

Register now or sign in using your IBM ID and password.

Regular expressions can provide a powerful way to work with text. Using regular expressions, you can do complex validation of user input, parse user input and file contents, and reformat strings. PHP provides simple methods that let you use POSIX and PCRE regular expressions. This article discusses the differences between POSIX and PCRE, and how you can use regular expressions and PHP V5.

Objectives

This tutorial will get you up and running with PHP's regular expressions by focussing on simple methods that let you use POSIX and PCRE regular expressions. We will discuss the differences between POSIX and PCRE, and how you can use regular expressions and PHP V5. You'll learn how, when, and why to use regular expressions.


Prerequisites


System requirements

You'll be able to complete this tutorial on any Microsoft Windows or UNIX-like system (including Mac OS X and Linux) that has PHP installed. Because we're covering what's built into PHP, you won't need anything more than PHP installed on your system.



Duration

Under two hours


Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed