const 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+\"/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\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+\\"', '')
const str = `
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"`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions