答案 0 :(得分:2)
PHP
有一个名为*SKIP/*FAIL
的好功能(名为回溯控制动词,因为@Federico指出正确):
"[^"]+"(*SKIP)(*FAIL) # everything to the left will be ignored
| # or
\b(\w+)\b # a word surrounded by boundaries
<小时/>
在PHP
中,这将是:
$regex = '~"[^"]+"(*SKIP)(*FAIL)|\b(\w+)\b~';
$string = 'this one "but this one not" but again this one';
preg_match_all($regex, $string, $matches);
print_r($matches);
答案 1 :(得分:0)