V
V
Viktor2016-04-25 18:50:08
JavaScript
Viktor, 2016-04-25 18:50:08

How to get rid of commas in regex output?

How to get rid of commas in regex output?
What would be the numbers without (-) and commas

var str = "My number is: 122-325-557-907";
var reg = /([^-,])+/gi;
console.log(str.match(reg).toString());

The output is
My number is: 122,325,557,907

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2016-04-25
@kani339

var str = "My number is: 122-325-557-907";
var reg = /([^-,])+/gi;
console.log(str.match(reg).join(""));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question