简体   繁体   English

正则表达式得到一个词,如果不用引号引起来

[英]Regex to get a word if not wrapped by quotation

If we have: 如果我们有:

$text = 'Jame is sleeping but pretend that is "studying"';

Now i need a regex to get all words after is but if is not wrapped by double or single quotations. 现在我需要一个regex来获取所有的话后, is ,但如果不是由双或单引号包裹。

the result should be just sleeping and not studying . 结果应该是sleeping而不是studying

This is pretty simple actually: 实际上,这很简单:

is\s(\w+)

You can make it a bit more liberal: 您可以使其更加自由:

is\s([^\s"']+)

Try this: 尝试这个:

is (\w+)

Working example 工作实例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM