Results 1 to 3 of 3

 

Thread: preg_match problem

  1. #1
    Registered User

    Status
    Offline
    Join Date
    Sep 2003
    Posts
    315
    Thanks
    28
    Thanked 19 Times in 16 Posts


    Hi I've got a string of text like:

    "A generous 4GB Memory ensures multitasking isn't a problem while the 500GB Hard Drive provides you with vast amounts of storage space for all your multimedia files..."

    And I want to extract the hard drive size with preg_match in php.

    if(preg_match("/( [0-9]GB)(.+?)GB Hard Drive/", $description,$hdd)) {
    print_r($hdd);
    }

    I can't figure out how to do it, despite reading multuple regexp tutorials. Anyone know how to code this?

    Thanks

    Tom

  2. #2
    Registered User

    Status
    Offline
    Join Date
    Aug 2010
    Posts
    63
    Thanks
    2
    Thanked 10 Times in 8 Posts
    Depending on your version of php, you can use...

    /\d+GB Hard Drive/

  3. #3
    Registered User

    Status
    Offline
    Join Date
    Aug 2010
    Posts
    63
    Thanks
    2
    Thanked 10 Times in 8 Posts
    Quote Originally Posted by annyphp View Post
    That has absolutely nothing todo with preg problem, if you're going to spam every thread with your crappy website then at least have the deceny to link to something usefull on it. I hope you're banned for life.



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2