简体   繁体   English

匹配特定句子之外的单词

[英]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: 您可以使用PCRE动词(*SKIP)(*FAIL)来匹配和跳过 LHS上交替出现的任何内容 ,如下所示:

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

RegEx Demo 正则演示

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

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