This appears to be strange behavior, or perhaps I don't understand regular expressions so well...
I'm using this to find all the xref and trailer objects in a PDF file:
preg_match_all('@(
xref?
)|(\strailer\s)@',$pdfcontent,$matches,PREG_OFFSET_CAPTURE);
print_r gives me this:
Array
(
[0] => Array
(
[0] => Array
(
[0] =>
xref
[1] => 13235519
)
[1] => Array
(
[0] =>
trailer
[1] => 13299371
)
)
[1] => Array
(
[0] => Array
(
[0] =>
xref
[1] => 13235519
)
[1] => Array
(
[0] =>
[1] => -1
)
)
[2] => Array
(
[0] =>
[1] => Array
(
[0] =>
trailer
[1] => 13299371
)
)
)
Why is there a position of -1 for xref?