1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Regex match space or nothing

Discussion in 'PHP' started by Silver89, Sep 26, 2011.

  1. #1
    I'm trying to match the following:

    4acres
    4 acres
    44 acres

    but it only works if there is a space at the moment:

    
    preg_match("/([0-9]+)\sacres/i", $row[5], $found);
    
    PHP:
    I tried the following but no luck ..

    
    preg_match("/([0-9]+)([\s|])acres/i", $row[5], $found);
    
    PHP:
     
    Silver89, Sep 26, 2011 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    Try following

    
    preg_match_all('/\d*\s*acres/i', $row[5], $found);
    
    Code (markup):
     
    mastermunj, Sep 26, 2011 IP
  3. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #3

    try this..
    
    preg_match("/[0-9]+[ ]?acres/i", $row[5], $found);
    
    PHP:
     
    JohnnySchultz, Sep 28, 2011 IP