How could I find string between [[
]]
? After searching a answer I find this method below, but I cannot find the regular expression for [[
]]
, neither for {{
}}
.
What I want to do is to find e.g. [[abc]]XXXXXXXXXX[[def]]
, and save abc
, def
as a ArrayList.
String s = "[[abc]]XXXXXXXXXX[[def]]";
Pattern p = Pattern.compile("[[(.*?)]]")
Matcher m = p.matcher(s);
if (m.find()) {
System.out.println(m.group(i)); // => "abc","def"
}