PHP Tutorial

A web server programming language.

PHP Regular Expressions

PHP Regular Expressions

A regular expression is a sequence of characters that forms a search pattern.

PHP uses PCRE (Perl Compatible Regular Expressions).

Common Functions:

  • preg_match() - Returns 1 if pattern was found in string, 0 if not
  • preg_match_all() - Returns the number of times pattern was found
  • preg_replace() - Returns a new string where matched patterns have been replaced

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics