我正在尝试构建一个Java正则表达式来匹配".jar!
".
The catch is that I don t want the matcher to consume the exclamation mark. I tried using Pattern.compile("\.jar(?=!)")
but that failed. As did escaping the exclamation mark.
有人能让这个工作吗,还是这是JDK的错误?
更新:我感觉自己像个白痴,Pattern.compile("\.jar(?=!)")
确实可行。我之前使用了Matcher.matches()而不是Matcher.find()。