I'm trying to construct a regexp that parses for a repeating group with a known min and max qty. Here's what I'm trying:
<?php
/
Here's the record layout.....
Field Format
Record ID PIC X(2)
Count PIC 9(2)
PAN #1 PIC X(19)
PAN #2 PIC X(19)
PAN #3 PIC X(19)
PAN #4 PIC X(19)
CR LF
(Count tells me how many PANs to expect (1-4).)
/
//Here's an example record:
$xTest = "D1041234567890123456781123456789012345678212345678901234567831234567890123456784".chr(13).chr(10);
//Here's a test regex...
eregi("D1"."([ |0-9]{2})"."([ |0-9]{19}){1,4}\r\n",$xTest,$aDetail);
while ( list($Key,$Val) = each($aDetail) )
{
print($Key." : ".$Val."<br>");
};
?>
The eregi only grabs the last pan.
i.e.:
$aDetail[1] == "04"
$aDetail[2] == "1234567890123456784"
$aDetail[3]-[9] are empty.
I expect $aDetail[2]-[5] to have all of the PANs.
What am I missing in the regex?