I'm trying to extract mark-up from a string. I'm part way there but am having trouble with commas in my pattern.
Take this example input string :
Lorem ipsum dolor sit amet, <that index="8"/>consectetur adipiscing elit. <that index="4"/>Sed metus sem, facilisis id nibh eget, <that index="6,2"/>accumsan tristique nisl. Proin iaculis dignissim tincidunt.I said : <that index="9,1"/>
I wish to extract the tags including the attribute 'index'.
I need both variations, ie patterns without and with commas in the attribute.
If I do this :
$haystack = 'Lorem ipsum dolor sit amet, <that index="8"/>consectetur adipiscing elit. <that index="4"/>Sed metus sem, facilisis id nibh eget, <that index="6,2"/>accumsan tristique nisl. Proin iaculis dignissim tincidunt.I said : <that index="9,1"/>';
$regex = '<that index="[0-9,]"\/>';
preg_match_all ( '/' . $regex . '/i', $haystack, $thats );
The array $thats only contains this :
(
[0] => Array
(
[0] => <that index="8"/>
[1] => <that index="4"/>
)
)
So clearly I am doing something wrong with how I use the comma in the pattern, because it omits those with commas.
Could someone please advise. Thank you.