|
Posted by Nicholas Sherlock on 02/04/06 02:04
David Wahler wrote:
> Nicholas Sherlock wrote:
>> /\[download:[^0-9]*([0-9]+)(,[0-9]+)*\]/i
>>
>> When I try it, it only returns the first and last items (Ie. "12",
>> ",28"). What am I missing?
>
> (quote)
> When a capturing subpattern is repeated, the value captured is the
> substring that matched the final iteration. [...]
> (end quote)
>
> So, it doesn't look like you can use regular expressions to split a
> string like that. If you need to split based on a real regular
> expression rather than a fixed string, check out pcre_split.
Thanks, I didn't realize my pattern would be recursive/repetitive. As I
don't really need to get each argument separately, I changed it to:
/\[download:[^0-9]*([0-9]+(,[0-9]+)*)+\]/i
Which returns for me the whole 1,2,3,4 block as a matched pattern,
perfect :).
Cheers,
Nicholas Sherlock
[Back to original message]
|