By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,400 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,400 IT Pros & Developers. It's quick & easy.

regex question

P: n/a
I need to remove non digits from a number.

I thought I could do this:

var phone='22-p67s82';
var re=/\D/g;
phone=phone.replace(re,'');

alert(phone) yields: 22-p67s82

What dumb thing am I missing. That regex removes nothing.

(I'd leave the non digits in but it's not my site)

Cheers,
Jeff

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sorry.... My mistake, I had this in a perl heredoc and I needed to
escape the "\"
Jeff

Jeff Thies wrote:

I need to remove non digits from a number.

I thought I could do this:

var phone='22-p67s82';
var re=/\D/g;
phone=phone.replace(re,'');

alert(phone) yields: 22-p67s82

What dumb thing am I missing. That regex removes nothing.

(I'd leave the non digits in but it's not my site)

Cheers,
Jeff

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.