too many matches regex
- From: cate <catebekensail@xxxxxxxxx>
- Date: Sun, 15 Jan 2012 21:33:24 -0800 (PST)
$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
)
)
.
- Follow-Ups:
- Re: too many matches regex
- From: Curtis Dyer
- Re: too many matches regex
- From: Michael Fesser
- Re: too many matches regex
- Prev by Date: Re: Implied cast differs from explicit cast
- Next by Date: Re: Implied cast differs from explicit cast
- Previous by thread: Re: Implied cast differs from explicit cast
- Next by thread: Re: too many matches regex
- Index(es):