regex question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff Thies

    #1

    regex question

    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.rep lace(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

  • Jeff Thies

    #2
    Re: regex question

    Sorry.... My mistake, I had this in a perl heredoc and I needed to
    escape the "\"


    Jeff

    Jeff Thies wrote:[color=blue]
    >
    > 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.rep lace(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[/color]

    Comment

    Working...