regex question

Giganews Newsgroups
Subject: regex question
Posted by:  Jeff Thies (cyberje…@sprintmail.com)
Date: Thu, 04 Sep 2003

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

Replies