Home > PHP > Function > PCRE > preg_match()

preg_match()

preg_match - Perform a regular expression match

Syntax

int preg_match ()

Arguments

-

Description

Searches subject for a match to the regular expression given in pattern.

Version

PHP 4, 5

Return value

preg_match() returns the number of times pattern matches. That will be either 0 times (no match) or 1 time because preg_match() will stop searching after the first match. preg_match_all() on the contrary will continue until it reaches the end of subject. preg_match() returns FALSE if an error occurred.