Using regular expressionssometimes known as regexis a powerful and concise way of writing a rule that identifies a particular string format. Because they can express quite complex rules in only a few characters, if you have not come across them before, regular expressions can look very confusing indeed.
At its very simplest, a regular expression can be just a character string, where the expression matches any string that contains those characters in sequence. At a more advanced level, a regular expression can identify detailed patterns of characters within a string and break a string into components based on those patterns.
Types of Regular Expression
PHP supports two different types of regular expressions: the POSIX-extended syntaxwhich is examined in this lessonand the Perl-Compatible Regular Expression (PCRE). Both types perform the same function, using a different syntax, and there is really no need to know how to use both types. If you are already familiar with Perl, you may find it easier to use the PCRE functions than to learn the POSIX syntax.
Documentation for PCRE can be found online at www.php.net/manual/en/ref.pcre.php.