php preg_match word only code example
Example 1: php preg match space or start of string
/\b(stackoverflow)\b/
Example 2: php match copy match
$subject = "E:[email protected] I:100955";
$pattern = "/^E:(?<contact>\w+) I:(?<id>\d+)$/";
if (preg_match($pattern, $subject,$matches)) {
print_r($matches);
}