简体   繁体   中英

Match word outside of specific sentence

I was wondering if it's possible to match a word outside of a sentence.

This is the regex I have so far:

/(exchange|occasion|second hand)/im

Now I only want to match these words outside of this sentence:

Shown prices, for exchange of ocassions are only for indication.

But I'm not sure how to go about this.

You can use PCRE verb (*SKIP)(*FAIL) to match and skip anything on LHS of an alternation like this:

/Shown prices, for exchange of ocassions are only for indication\.(*SKIP)(*F)|\b(exchange|occasion|second hand)\b/i

RegEx Demo

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