简体   繁体   中英

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.

the result should be just sleeping and not 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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