Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我们有:
$text = 'Jame is sleeping but pretend that is "studying"';
现在我需要 aregex来获取所有单词,is但如果没有被双引号或单引号包裹。
regex
is
结果应该是公正sleeping而不是studying。
sleeping
studying
这实际上很简单:
is\s(\w+)
你可以让它更自由一点:
is\s([^\s"']+)
尝试这个:
is (\w+)
工作示例