Input
preg_match usage
PHP regular expression match
$retval = preg_match($pattern, $content [, array &$matches [, int $flags = 0 [, int $offset = 0]]]) (this page is using $flags=PREG_OFFSET_CAPTURE)
Notes on preg_match behavior
- $matches[0] is full pattern match and $matches[1] is subpatten match for first parentheses subpattern and so on.
- The regex pattern must be delimited by a valid delimiter. e.g.
/abc/
,#abc#
, etc. - The modifier flag “i” after / is specified to ignore case while matching. You can combine multiple flags. For a full list if flags you can visit PHP: possible modifiers in regex patterns – manual.
- Php preg_match follows PCRE – Perl compatible regular expressionss.
- Official document for preg_match can be viewed at PHP: preg_match manual.
- Also visit: Regular expression – Wikipedia.