ID: 25618
Updated by: [EMAIL PROTECTED]
Reported By: yurtesen at ispro dot net dot tr
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: FreeBSD 4.8-STABLE
PHP Version: 4.3.3
New Comment:
You just need to make your * non-greedy there.
eg.
"/<a.*href=\"(.*)\".*>(?:<.*>)*?(.*)<\/a>/iU"
Previous Comments:
------------------------------------------------------------------------
[2003-09-21 07:46:02] yurtesen at ispro dot net dot tr
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
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25618&edit=1