FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » too many matches regex
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
too many matches regex [message #176661] Mon, 16 January 2012 05:33 Go to previous message
cate is currently offline  cate
Messages: 12
Registered: January 2012
Karma:
Junior Member
$s = '1 2 20 - 31 55 56 77 - 88 97 - 99';

$patRange = '/((\d+) *- *(\d+))/';

$matches = array();
preg_match_all($patRange, $s, $matches);

I expected to see an array with 3 matches for each of the there number
"ranges" found in the
string $s (20 - 31, 20 and 31).... I see 4. Why? Need some insight
from a jones. I don't understand what I'm seeing.

Thank you.

Array (PREG_SET_ORDER)
(
[0] => Array
(
[0] => 20 - 31
[1] => 20 - 31
[2] => 20
[3] => 31
)

[1] => Array
(
[0] => 77 - 88
[1] => 77 - 88
[2] => 77
[3] => 88
)

[2] => Array
(
[0] => 97 - 99
[1] => 97 - 99
[2] => 97
[3] => 99
)

)

Array (PREG_PATTERN_ORDER)
(
[0] => Array
(
[0] => 20 - 31
[1] => 77 - 88
[2] => 97 - 99
)

[1] => Array
(
[0] => 20 - 31
[1] => 77 - 88
[2] => 97 - 99
)

[2] => Array
(
[0] => 20
[1] => 77
[2] => 97
)

[3] => Array
(
[0] => 31
[1] => 88
[2] => 99
)

)

Array (null)
(
[0] => Array
(
[0] => 20 - 31
[1] => 77 - 88
[2] => 97 - 99
)

[1] => Array
(
[0] => 20 - 31
[1] => 77 - 88
[2] => 97 - 99
)

[2] => Array
(
[0] => 20
[1] => 77
[2] => 97
)

[3] => Array
(
[0] => 31
[1] => 88
[2] => 99
)

)
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: php with openssl in static mode (binaries for windows)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 14:23:46 GMT 2024

Total time taken to generate the page: 0.06638 seconds