const regex = new RegExp('\\d{2}\\.\\d+', 'g')
const str = `Добрый день.
Как сформировать регулярное приложение, чтобы из подобного массива можно было вытаскивать координаты.
[3] => 17629,17629,"ПОНТОННЫЙ, ВОКЗАЛ",59.785067,30.627792,0,2,bus
[4] => 17630,17630,ДОРОГА НА КОЛПИНО,59.775908,30.653787,0,2,bus
К примеру чтобы я получил массив
[0] => 59.785067
[1] => 30.627792`;
// 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