functions-online

Regular Expression

Execute and test PHP functions for manipulating data through regular expressions.

The syntax for patterns used in these functions closely resembles Perl 5. The expression must be enclosed in the delimiters, a forward slash (/), for example. Delimiters can be any on-alphanumeric, non-whitespace ASCII character except the backslash (\) and the null byte. If the delimiter character has to be used in the expression itself, it needs to be escaped by backslash.

preg_filter

preg_filter() is identical to preg_replace() except it only returns the matches. For details about how this function works, read the preg_replace() documentation.

preg_grep

Returns the array consisting of the elements of the $input array that match the given $pattern.

preg_match

Searches $subject for all matches to the regular expression given in $pattern and puts them in $matches in the order specified by $flags.

preg_match_all

Searches $subject for all matches to the regular expression given in $pattern and puts them in $matches in the order specified by $flags.

After the first match is found, the subsequent searches are continued on from end of the last match.

preg_replace

Searches $subject for matches to $pattern and replaces them with $replacement.

preg_quote

preg_quote() takes $str and puts a backslash in front of every character that is part of the regular expression syntax. This is useful if you have a run-time string that you need to match in some text and the string may contain special regex characters.

The special regular expression characters are: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -

preg_split

Split the given string by a regular expression.