Home »
Imported messages »
comp.lang.php »
too many matches regex
too many matches regex [message #176661] |
Mon, 16 January 2012 05:33 |
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
)
)
|
|
|
Goto Forum:
Current Time: Thu Nov 28 16:51:42 GMT 2024
Total time taken to generate the page: 0.04720 seconds