Максим Ученик,
для новых браузеров можно так ...
let str = "M371,212 371,382 51,382 51,372 94,372 94,291 206,291 206,211 252,211 252,292 324,293 325,212 371,212";
let regexp = /(?<a>\d+),(?<b>\d+)/g;
let match = str.matchAll(regexp);
let arr = Array.from(match, ({groups : {a,b}}) => [a, b].map(Number));
console.log(arr)