search

Home  >  Q&A  >  body text

java - 正则表达式如何对字符串取反?

有两个字符串:

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

单位:元

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

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

高洛峰高洛峰2785 days ago718

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-18 10:28:20

    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

    reply
    0
  • Cancelreply