我有这样的东西
$matches = array();
preg_match_all('/(`.+`)(\s+AS\s+`.+`)?/i', '`foo` AS `bar`', $matches);
print_r($matches);
结果是
Array
(
[0] => Array
(
[0] => `foo` AS `bar`
)
[1] => Array
(
[0] => `foo` AS `bar`
)
[2] => Array
(
[0] =>
)
)
所以,问题是为什么我没有' AS `bar`' in $matches[2][0]
?(如果我从正则表达式中删除“?”符号,我会得到它,但我需要“?”:))