this regex match pattern works fine for what i want, apart from in some situations:
Code:
([0-9]+) +([0-9]+) +obj.*/Length +([0-9]+)( +([0-9]) +(R))?
here's some example data it works fine for:
Code:
19 0 obj
<< /S 36 /Filter /FlateDecode /Length 20 0 R >>
from the bracketed parts from the pattern from the above data i get 19 0 20 0 R. that's good. that's what i want.
here's another example of data that also works fine:
Code:
15 0 obj
<< /Length 1848 /Filter [ /FlateDecode ] >>
from that i get 15 0 1848 which is again good.
here's a bit of data that my pattern goes wrong with:
Code:
810 0 obj
<< /Mask [ 3 3 ] /Type /XObject /Subtype /Image /Width 16 /Height 16
/BitsPerComponent 8 /ColorSpace 820 0 R /Filter /FlateDecode /Length 808 0 R
/ID 809 0 R >>
the reason it's wrong for me, is because it matches 820 0 R that follows on from /ColorSpace rather than 808 0 R that follows on from /Length. i don't know how to change my pattern to make sure it gets only the info from after /Length.
there's basically 2 situations that can occur as the first 2 bits of data show. a number, a number and an R after /Length, or a number after /Length. that's the info i want to extract (as well as the very first two numbers, but that bit's working fine). so there's only a problem when there's a number, number, R sequence that comes before and doesn't follow /Length. it matches it, even though it doesn't follow /Length.
how can i change my pattern to make sure i only get informatin that follows /Length's?
btw this i'm using this from a cocoa (os x) wrapper that's made up of pcre 4.0 regex

thanks.