Alex Bogias
Alex Bogias

Reputation: 1880

regexp on finding elements in PHP Simple HTML DOM Parser

How can i "find" all elements with those id:

ctl00_cphContent_ctl05_Panel01,

ctl00_cphContent_ctl06_Panel01,

ctl00_cphContent_ctl07_Panel01,

ctl00_cphContent_ctl08_Panel01, etc...

I tried

foreach($html->find('a#ctl00_cphContent_ctl'.*.'_Panel01') as $positions) { echo "Test!";}

But it doesn't work! Can someone help me please? I search but didn't find something similar...

Upvotes: 1

Views: 2599

Answers (1)

Dom
Dom

Reputation: 3080

From reading the simple HTML DOM parses documentation http://simplehtmldom.sourceforge.net/manual.htm#section_find, I don't think that it includes full regex functionality. However it does seem to have basic matching. Try this:

$html->find( '[id^=ctl00_cphContent_ctl]' )

Obviously this wont just match id tags like ctl00_cphContent_ctl05_Panel01, but will also match things like ctl00_cphContent_ctrandomstuffhere. But it doesn't appear to be possible to do a full regexp match in the way you want.

Upvotes: 3

Related Questions