Input
preg_match_all usage
PHP regular expression match
$retval = preg_match_all($pattern, $content [, array &$matches [, int $flags = 0 [, int $offset = 0]]]) (this page is using $flags=PREG_SET_ORDER|PREG_OFFSET_CAPTURE)
Notes on preg_match_all behavior
- Above flags can be combined with PREG_OFFSET_CAPTURE to capture the offset of the match.
- For flag PREG_SET_ORDER $match[0] contains first set of matches (pattern and its subpattern if any), $match[1] contains second 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_all follows PCRE – Perl compatible regular expressionss.
- Official document for preg_match_all can be viewed at PHP: preg_match_all manual.
- Also visit: Regular expression – Wikipedia.