const regex = /(?:[^ ]*\ ){2}([^ ]*)/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:[^ ]*\\ ){2}([^ ]*)', '')
const str = `04/04/19 11:54:10 7.4 78 3.9 2.1 0.0 63 0.00 0.00 1000.0 ENE 0 km/h C mb mm --- --- 0.20 167.00 --- 23.3 41 7.2 --- 7.4 11:49 2.4 5:18 9.7 11:15 9.7 11:15 1000.6 0:12 998.3 5:31 2.16 2.16 4.8 7.2 --- 1.0 0.01 311 --- 0.00 0 0 0 0 0 0 0 0 0 0 `;
// 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