Reputation: 1861
var ssn = "123-45-6789";
What is the javascript regex to return only the numeric portion of SSN? I need to test that they entered exactly 9 digits.
I don't know why I just have to re-learn regex the few times a year I need it. I've got a block for regex.
Thanks ever so much.
Upvotes: 1
Views: 435
Reputation: 44642
var digits = ssn.replace(/\D/g,'');
Simply removes all non-digit characters.
Upvotes: 7