问题
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...
回答1:
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.
来源:https://stackoverflow.com/questions/13429755/regexp-on-finding-elements-in-php-simple-html-dom-parser