Re: preg_match question...
| From: | Frank Stanovcak | Date: | Fri, 06 Feb 2009 14:14:41 +0000 |
| Subject: | Re: preg_match question... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287811@lists.php.net to get a copy of this message | ||
""bruce"" <bedouglas@earthlink.net> wrote in message
news:234801c98863$88f27260$0301a8c0@tmesa.com...
> hi...
>
> trying to figure out the best approach to using preg_match to extract the
> number from the follwing type of line...
>
> " 131646 sometext follows.."
>
> basically, i want to extract the number, without the text, but i have to
> be
> able to match on the "text"
>
> i've been playing with different preg_match regexs.. but i'm missing
> something obvious!
>
> thoughts/comments..
>
How about
preg_match('#(\d+)(.)+#',$haystack,$match)
if I remember right
$match[0] would be all of it
$match[1] would be the numbers
$match[2] would be the text