Regular Expression

A regular expression, or regex, is a sequence of characters that specifies a search pattern. PHP currently uses the PCRE library, and used to have 2 such libraries.

<?php

    preg_match('/(foo)(bar)(baz)/', 'foobarbaz', $matches, PREG_OFFSET_CAPTURE);
    print_r($matches);

?>

Documentation

See also How to Use PHP Regular Expressions for Pattern Matching and Data Validation and Getting Started with PHP Regular Expressions.

Related : Question Mark ?, Regexploit, Reverse Regex, Star *, Wildcard, Escape Character, Perl Compatible Regular Expressions (PCRE), Preg_match