什么是匹配字符串末尾的单词模式的正则表达式? 例如,以下内容应匹配“qwerty [numeric] [alpha]”:
"blah blah qwerty 8z"
"blahh blahh qwerty 4vx"
但不是:
"blah blah qwerty 8"
"blahh blahh qwerty 4"
答案 0 :(得分:3)
$re = "/(\\w+\\s+\\d+\\w+)$/m";
$str = "blah blah qwerty 8z\nblahh blahh qwerty 4vx";
preg_match_all($re, $str, $matches);
答案 1 :(得分:1)
$matches = null;
$returnValue = preg_match('/^.+(\d+[a-z]+)$/', 'blah blah qwerty 8z', $matches);
print_r($matches);