i cant figure out how i manage to solve the problem of getting information out of square brackets as well as the normal ones. I want the content of them both. i tried:

Pattern p = Pattern.compile("\\[[^\\]]*\\]"); 
Pattern p1 = Pattern.compile("\\[|\\([^\\)]*|[^\\]]*\\]|\\)"); 
Pattern p2 = Pattern.compile("\\[|\\([^{\\]|\\)}]*\\]|\\)");

p works perfectly for the squared ones only and then i tried to add the normal braces, but no success.
a sample of a string would be

"(info1) something-uninteresting [info2] s.u. [info3] s.u. (info4)"
有帮助吗?

解决方案

Try the following:

[\\[(][^\\])]*[\\])]

其他提示

Try the following:

(\\(.*?\\)|\\[.*?\\])*?
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top