java正则表达式提取方括号内的内容 [英] java regular expression to extract content within square brackets
本文介绍了java正则表达式提取方括号内的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
输入行位于
Item(s): [item1.test],[item2.qa],[item3.production]
你能帮我写一个Java正则表达式来提取
Can you help me write a Java regular expression to extract
item1.test,item2.qa,item3.production
来自输入行的
?
from above input line?
推荐答案
更简洁一点:
String in = "Item(s): [item1.test],[item2.qa],[item3.production]";
Pattern p = Pattern.compile("\\[(.*?)\\]");
Matcher m = p.matcher(in);
while(m.find()) {
System.out.println(m.group(1));
}
这篇关于java正则表达式提取方括号内的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文