Mega Code Archive

 
Categories / Php / Strings
 

Put the word boundary character to the test

<? $text = "pot post pat patent"; if ( preg_match( "/\bp\w+t\b/", $text, $array ) ) {   print "<pre>\n";   print_r( $array );   print "</pre>\n"; } ?>