High performance simple Java regular expressions

前端 未结 4 530
北海茫月
北海茫月 2021-02-08 03:44

Part of the code I\'m working on uses a bunch of regular expressions to search for some simple string patterns (e.g., patterns like \"foo[0-9]{3,4} bar\"). Currently, we use sta

4条回答
  •  既然无缘
    2021-02-08 04:48

    You could try using the Pattern.matches() static method which would just return the boolean. That wouldn't return a Matcher object so it could help with the memory allocation issues.

    That being said the regex pattern would not be precompiled so it would be a performance vs resources thing at the point.

提交回复
热议问题