Java 无法匹配字符串";“帮助”;“在字符串中”;[帮助]”;使用正则表达式
我无法使此项正确匹配。它只打印“[help]”,但我希望它与括号内的字符匹配 想要: 代码:Java 无法匹配字符串";“帮助”;“在字符串中”;[帮助]”;使用正则表达式,java,regex,Java,Regex,我无法使此项正确匹配。它只打印“[help]”,但我希望它与括号内的字符匹配 想要: 代码: Pattern p = Pattern.compile("\\[(\\w+)\\]"); Matcher m = p.matcher("[help]"); m.find(); for (int i=0;i<m.groupCount(); i++) { System.out.println(m.group(i
Pattern p = Pattern.compile("\\[(\\w+)\\]");
Matcher m = p.matcher("[help]");
m.find();
for (int i=0;i<m.groupCount(); i++) {
System.out.println(m.group(i));
}
Pattern p=Pattern.compile(\\[(\\w+\\\]);
Matcher m=p.Matcher(“[help]”);
m、 查找();
对于(int i=0;i你需要检查你需要检查你可能需要更多的反斜杠。Java REs:)通常是这样的(在我提交到ideone之前就被击败了),你可能需要更多的反斜杠。Java REs:)通常是这样的(我还没完成向ideone提交的任务就被打败了)
Pattern p = Pattern.compile("\\[(\\w+)\\]");
Matcher m = p.matcher("[help]");
m.find();
for (int i=0;i<m.groupCount(); i++) {
System.out.println(m.group(i));
}
for (int i = 0; i <= m.groupCount(); i++) {