#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Montreal, Canada
    Posts
    72
    Rep Power
    15

    Red face Getting a Number From a String


    OK I have some text which usually looks like this below

    "Sometext Othertext (xxx# 1234567)"

    I want to extract the number so using REGEXP just get "1234567" when I do the check against the string above. Any ideas?

    Thx in advance.
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,247
    Rep Power
    9400
    If those are the only digits then all you need is \d+. If not, append a (?=\)).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Montreal, Canada
    Posts
    72
    Rep Power
    15
    How do you code that in PHP?
    Visit my PHP V-Portal.
    http://www.naijaryders.com
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Check out the manual page for [PHPNET="preg_match"]preg_match[/PHPNET]

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Montreal, Canada
    Posts
    72
    Rep Power
    15
    Thx ........... worked like a charm
    Visit my PHP V-Portal.
    http://www.naijaryders.com

IMN logo majestic logo threadwatch logo seochat tools logo