const regex = /(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\-?\\d+(\\.\\d+)?),\\s*(\\-?\\d+(\\.\\d+)?)', '')
const str = `1.3626104100298,44.0313777738606,0 -121.3627743244628,44.03123252081081,0 -121.3627794325398,44.03122812311533,0 -121.3627843389654,44.03122393122449,0 -121.3627892667884,44.0312197526747,0 -121.3627942147613,44.0312155874754,0 -121.3627991841185,44.03121143471726,0 -121.3628041748603,44.03120729440029,0 -121.3628091845174,44.03120316834296,0 -121.3628142168063,44.03119905471752,0 -121.3628192704925,44.0311949544332,0 -121.3628243430812,44.03119086750853,0 -121.3628294370801,44.03118679482493,0 -121.362834551216,44.0311827345917,0 -121.3628396867492,44.03117868769964,0 -121.3628448411978,44.03117465506718,0 -121.3628500170308,44.03117063487584,0 -121.3621653794692,44.03071984342947,0 -121.3619768731163,44.03100429635388,0 -121.3626104100298,44.0313777738606,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