Java正则表达式提取方括号内的内容

 

问题描述:

输入线在下面

Item(s): [item1.test],[item2.qa],[item3.production]

你能帮我写一个Java正则表达式来提取

item1.test,item2.qa,item3.production

从上方输入线?


 

第 1 个答案:

更加简洁:

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));
}

我决定尝试一些实验,以了解关于堆栈帧大小以及当前执行的代码在堆栈中的距离的发现。我们可能在这里调查两个有趣的问题:当前代码有多少层深入堆栈?当前方法在达到a之前可以达到多少级别的递归StackOve ...