You can extract myid without regex
$url = "index.php?foo=Y&myid=123456&bar=2";$urlParts = parse_url($url);$status 
= parse_str($urlParts['query'], $output);if (false !== $status) {    print_r 
($output);}

CheersMohammed
> Date: Sat, 26 Mar 2011 21:05:53 +1200
> From: [email protected]
> Subject: [phpug] learning regex preg_match
> To: [email protected]
> 
> i want to extract a match from a string. I have these working:
> 
> /myid=[0-9][0-9][0-9]/
> 
> on "index.php?foo=Y&myid=123456&bar=2"
> with the result
> 
> Array
> (
>     [0] => Array
>         (
>             [0] => myid=123
>         )
> 
> )
> 
> or
> 
> /myid=[0-9]{7}|[0-9]{6}|[0-9]{5}|[0-9]{4}/
> 
> Array
> (
>     [0] => Array
>         (
>             [0] => 123456
>         )
> 
> )
> 
> "myid" is between 4 and seven digits and i need to get the full number hence 
> why i check for 7 first.
> 
> /myid=[0-9]{7}|myid=[0-9]{6}|myid=[0-9]{5}|myid=[0-9]{4}/
> 
> Array
> (
>     [0] => Array
>         (
>             [0] => myid=123456
>         )
> 
> )
> 
> Just tried this... it works, it is what i want, but it just seems way OTT. Is 
> there a simpler way?
> 
> Much cleaner would be a way of extracting just the digits after ensuring it 
> followed "myid=" but i can do that on a second call if needed.
> 
> TIA
> 
> -- 
> Michael
> 
> -- 
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]
                                          

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to