What kind of pattern you need to write to get, for example, the line 15, 43, 54, 2, 1, 23, 1, 6 ? That is, it is necessary to replace all characters (including spaces) with , - , and so that commas do not repeat.
var str = '15,43,54, 2, 1л23а1-4 6'; var myPattern = /\D/g; var strА = str.match(myPattern); //паттерн, который должен вернуть 15, 43, 54, 2, 1, 23, 1, 6 console.log(strА);
strA=str.split(myPattren).join(",")- nick_n_a