简体   繁体   中英

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM