const regex = /(?<=vertex\s)-?\d*\.?\d+|(?<=\G\s)-?\d*\.?\d+/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=vertex\\s)-?\\d*\\.?\\d+|(?<=\\G\\s)-?\\d*\\.?\\d+', 'g')
const str = `vertex
144.64329 -65.95227 -40.5391
244.25595 -77.64196 -51.07746
144.64738 23.13064 -40.53168
244.26259 67.13464 -51.0654
144.64968 -65.94874 36.17572
244.26407 -77.63749 46.41944
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// 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