How can I perform a partial match with java.util.regex.*?

后端 未结 7 1487
野的像风
野的像风 2020-11-30 03:16

I have been using the java.util.regex.* classes for Regular Expression in Java and all good so far. But today I have a different requirement. For example consider the patter

相关标签:
7条回答
  • 2020-11-30 04:04

    If you make each character of the regex optional and relax the multiplicity constraints, you kinda get what you want. Example if you have a matching pattern "aa(abc)+bbbb", you can have a 'possible match' pattern 'a?a?(a?b?c?)*b?b?b?b?'.

    This mechanical way of producing possible-match pattern does not cover advanced constructs like forward and backward refs though.

    0 讨论(0)
提交回复
热议问题