M
M
Mesuti2020-04-16 01:05:40
JavaScript
Mesuti, 2020-04-16 01:05:40

What regular expression to clear a phone number?

What would a regular expression look like to strip a phone number from spaces, parentheses, and hyphens?

+7 (111) 111-11-111

This does not help https://regex101.com/r/DM2Nyg/2/

console.log("+7 (111) 111-11-111".replace(/(\s|\(|\)|-)/, ''));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-04-16
@Mesuti

'+7 (111) 111-11-111 '.replace(/\D/g, '')
// "711111111111"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question