Option 1: If you want the {{text AND the braces}}
String ResultString = null;
try {
Pattern regex = Pattern.compile("=== FIRST KEYWORD ===[^{]*?(\\{\\{(?:.(?!}}))*.}})", Pattern.DOTALL);
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
ResultString = regexMatcher.group(1);
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}
Option 2: If you want to match the {{ text but NOT the braces
}}
String ResultString = null;
try {
Pattern regex = Pattern.compile("=== FIRST KEYWORD ===[^{]*?\\{\\{((?:.(?!}}))*.)}}", Pattern.DOTALL);
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
ResultString = regexMatcher.group(1);
}
} catch (PatternSyntaxException ex) {
// Syntax error in the regular expression
}