import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\S+\\s\\d+\\s_HOS_EXTENDED_\\s(\\d+\\.\\d+\\.\\d+\\.\\d+)\\s-\\s-\\s\\[\\S+\\s\\S+\\]\\s\\\"(?:GET|POST)\\s\\S+url=http[s]?\\S+\\.\\S+=\\S+(?:SELECT|CASE|WHEN|THEN)\\S+\\sHTTP\\/\\d+\\.\\d+\\\"";
final String string = "\n"
+ "dedi10.jnb2.host-h.net 0 _HOS_EXTENDED_ 129.232.136.66 - - [14/May/2019:09:35:07 +0200] \"GET /wp-json/oembed/1.0/embed?url=https%3A%2F%2Fwww.kdomainname%2F&format=xml%27%29%20AND%207814%3DCONVERT%28INT%2C%28SELECT%20CHAR%28113%29%2BCHAR%28106%29%2BCHAR%28112%29%2BCHAR%28120%29%2BCHAR%28113%29%2B%28SELECT%20%28CASE%20WHEN%20%287814%3D7814%29%20THEN%20CHAR%2849%29%20ELSE%20CHAR%2848%29%20END%29%29%2BCHAR%28113%29%2BCHAR%2898%29%2BCHAR%28118%29%2BCHAR%28122%29%2BCHAR%28113%29%29%29%20AND%20%28%27cipr%27%3D%27cipr HTTP/1.1\"";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
if (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