|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-09-21 09:21 UTC] rasmus@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 03:00:01 2025 UTC |
Description: ------------ If I have string <a HREF="linkhere"><font>texthere</a></font> I can extract the text 'linkhere' and 'texthere' with preg_match_all("/<a.*href=\"(.*)\".*><.*>(.*)<\/a>/iU", $line, $matches); But if the string is <a HREF="linkhere"><font><b>texthere</a></b></font> preg_match_all("/<a.*href=\"(.*)\".*>(?:<.*>)*(.*)<\/a>/iU", $line, $matches); doesnt work. It matches for "<font><b>texthere" I am trying to exclude <font><b> by matching repeatedly by (?:<.*>)* before the actual text I need. You can check out my php configuration from http://www.ispro.net/temp/phpinfo.php Reproduce code: --------------- <? $line = '<a HREF="linkhere"><font><b>texthere</a></b></font>'; preg_match_all("/<a.*href=\"(.*)\".*>(?:<.*>)*(.*)<\/a>/iU", $line, $matches); print_r($matches); ?> Expected result: ---------------- Array ( [0] => Array ( [0] => <a HREF="linkhere"><font><b>texthere</a> ) [1] => Array ( [0] => linkhere ) [2] => Array ( [0] => texthere ) ) Actual result: -------------- Array ( [0] => Array ( [0] => <a HREF="linkhere"><font><b>texthere</a> ) [1] => Array ( [0] => linkhere ) [2] => Array ( [0] => <font><b>texthere ) )