Display the drop-down list

preg_match()

« preg_last_error | preg_match_all »
<?php
$int 
preg_match (
    
// string $pattern
    
// string $subject
    
// [array &$matches]
    
?// [int $flags = 0]
    
  // [int $offset = 0]
);
?>
Result
$matches = [
  
=> 'PHP',
]
$int = 1
Examples
#1 preg_match  ("/php/i",
 
"PHP is the web scripting language of choice.",
 
$matches)
#2 preg_match  ('/\bweb\b/i',
 
"PHP is the web scripting language of choice.",
 
$matches)
#3 preg_match  ('/\bweb\b/i',
 
"PHP is the website scripting language of choice.",
 
$matches)
#4 preg_match  ("@^(?:http://)?([^/]+)@i",
 
"http://www.php.net/index.html",
 
$matches)
#5 preg_match  ('/[^.]+\.[^.]+$/',
 
"http://www.php.net",
 
$matches)
#6 preg_match  ('/(?P<name>\w+): (?P<digit>\d+)/',
 
"foobar: 2008",
 
$matches)
#7 preg_match  ("/^def/",
 
"abcdef",
 
$matches,
 
PREG_OFFSET_CAPTURE,
 
3)
#8 preg_match  ("/^def/",
 
"def",
 
$matches,
 
PREG_OFFSET_CAPTURE)
See also
preg_last_error, preg_match_all, preg_quote, preg_replace, preg_split