I have the following string:
<w:pPr>
<w:spacing w:line="240" w:lineRule="exact"/>
<w:ind w:left="1890" w:firstLine="360"/>
<w:rPr>
<w:b/>
<w:color w:val="00000A"/>
<w:sz w:val="24"/>
</w:rPr>
</w:pPr>
and I am trying to parse the "w:sz w:val" value using preg_match().
So far, I've tried:
preg_match('/<w:sz w:val="(\d)"/', $p, $fonts);
but this has not worked, and I'm unsure why?
Any Ideas?
Thank you in advance!
You were trying to capture only single-digit numbers. Try adding a + to make "one or more".
preg_match('/<w:sz w:val="(\d+)"/', $p, $fonts);
I prefer [0-9]+ for easier reading, and because it avoids the potentially funny need to double-up on \ symbols.
preg_match('/<w:sz w:val="([0-9]+)"/', $p, $fonts);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With