简体   繁体   English

用正则表达式查找除具有此模式的文本以外的任何文本

[英]find any text except text with this pattern with regex

I want to find any text except text with this pattern. 我想查找除具有此模式的文本以外的任何文本。 In other word, How can I inverse select with regex ? 换句话说,如何使用正则表达式进行逆选择?

\\+?(9892\\d{8})
\b(?=\w)(?!\+?(9892\d{8}))\b(\w*)

this is for the given regex. 这是给定的正则表达式。
the \\b is to find word boundary. \\ b是查找单词边界。
the positive look ahead (?=\\w) is here to avoid spaces. 前面的积极眼神(?= \\ w)在这里避免空格。
the negative look ahead over the original regex is to prevent matches of it. 原始正则表达式的负面展望是防止其匹配。
and finally the (\\w*) is to catch all the words that are left. 最后(\\ w *)将捕获所有剩余的单词。
the group that will hold the words is group 2. 包含单词的组是组2。

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

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