import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\{.*\\[type=(.*),\\s*reason=(.*)],\\s*data=.*\\}";
final String string = "[10:58:56] [INFO] [cn.qstec.gateway.filter.es.DaptSaveOrUpdateResponseGatewayFilterFactory] [] [-] [-] [返回体===>{code=1, state=false, message=upsert failed index [cards_house_translation] type _doc id hr1811-116-IH Exception Elasticsearch exception [type=illegal_argument_exception, reason=Document contains at least one immense term in field=\"article_translation\" (whose UTF8 encoding is longer than the max length 32766), all of which were skipped. Please correct the analyzer to not produce such terms. The prefix of the first immense term is: '[60, 104, 116, 109, 108, 32, 120, 109, 108, 110, 115, 58, 109, 115, 61, 34, 117, 114, 110, 58, 115, 99, 104, 101, 109, 97, 115, 45, 109, 105]...', original message: bytes can be at most 32766 in length; got 44979], data=}]";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html