SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help needed with regular expressions

    Hi Guys,
    I aint much use at the regular expressions, can somebody help me with this one?

    Here is the string

    Code:
    <p class="the-price"><div id="result13">2333.10</div><div id="showMessage13" class="mqstyle">Searching</div></p>
    												<p class="gbox"><!--<a href="#"><span>Arrange<br>
    													Cover</span></a>--></p>
    I want to extract the piece in bold. The number of the div id's will change, so need it to work in all situations.

    When I use this

    Code:
    s = s.replace(/[^\d\.]/g,'');
    It gives me all the numbers.

    Any help would be very much appreciated.

    Thanks in advance.

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    [edit]: whoops, just noticed this was in the javascript forum, not PHP forum. Sorry. the only thing that might be relevant between the languages is this regular expression for selecting the price as a group:

    Code:
    ([0-9]+(?:\.[0-9]{2})?)
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent Flow Force, thanks for your help.


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
  •