SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stripping numbers out of a string

    I have a string like this: $433.00

    As you can see it's a price with the Dollar sign, I need to convert that to an integer. How would I do that in Javascript?

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    try a thing like this

    Code JavaScript:
    var str = '$433.00';
    var re = /(\d+\.?\d+)/;
    var found = str.match(re);
    //["433.00", "433.00"]

    but I'm not a regex guru


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •