java - 正则表达式如何对字符串取反?
高洛峰
高洛峰 2017-04-18 10:26:20
0
1
725

有两个字符串:

XXXXXX编制单位:万科企业股份有限公司

单位:元

只想要匹配到第二个字符串,如何对字符串取反,即对“编制”取反,还有“投资”等词语也不能匹配到。

网上搜索一通都是对“字符”取反的......

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
黄舟

Because the label has python,我就说说python right

In fact, I don’t quite understand your purpose. I vaguely feel that the function you want is not the opposite,

If you just want to capture a certain part of the clauses in the regular expression, you can use 分组捕获

If you really want it取反,就用negative lookahead assertion,比如(?!投资)

If it is Java的话,你自己上网搜搜negative lookahead assertionJavahow to use it, it should be almost the same

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template