preg_match

PHP 4, PHP 5, PHP 7, PHP 8
preg_match - Perform a regular expression match

Example #1 Getting the domain name out of a URL

Result: domain name is: php.net

Example #2 Using named subpattern

Result: Array ( [0] => foobar: 2008 [name] => foobar [1] => foobar [digit] => 2008 [2] => 2008 )

Example #3 Find the string of text "php"


Example #4 Find the word "web"



Example #5 of preg_match



Function preg_match:

Regular Expressions (Perl-Compatible) Functions

Most used PHP functions

close