无论我如何尝试学习 RegEx 并实施它们,我都失败了。
下面:第一个值是输入字符串,冒号后的值是我需要的字符串中的术语。该术语将始终是 ->输入!(AZ)(数字)或计算!(AZ) (数字)
例如输入!A34 或计算!D93。
输入:需要用一些常量/值替换
我应该为此使用什么模式?
我的尝试:
模式 findMyPattern = Pattern.compile("(?:Input|" + "Calc!"
+ ")![a-zA-Z]\\d+");
匹配器 foundAMatch = findMyPattern.matcher(input);
HashSet hashSet = new HashSet();
而(foundAMatch.find()){
字符串 s = foundAMatch.group(0);
hashSet.add(s);
}