Connecting Tech Pros Worldwide Forums | Help | Site Map

regex and multiline problem

sinasalek
Guest
 
Posts: n/a
#1: Jul 17 '05
i have a problem below code :

[PHP]
<?php
$text='
<html dir="rtl">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<p><a href="http://www.google.com/">gfsdfgsdgdsfgsdgsfd</a></p>
<p>aasdfasfasfasf</p>
<p>fasfasfasfsad</p>
<p>sdfaafdadsfsdfa</p>
<p><A href=http://www.orkut.com/>
<img border="0" src="file:///D:/My%20Documents/My%20Pictures/mohsen.jpg"
width="480" height="640"></a></p>

</body>

</html>';
//$text='<a href="http://www.google.com/">gfsdfgsdgdsfgsdgsfd</a> <a
href="http://www.orkut.com/">';

preg_match_all('/(<a *href *=)(["\']*)(http:\/\/[^"=[color=blue]
>]*)(["\']*)(>)/',$text,$matches,PREG_PATTERN_ORDER);[/color]
print_r($matches);
?>
[/PHP]

it can find just one of two match string in text (<a
href="http://www.google.com/">). but after several tests, and after i put
two match strings in one line :
[PHP]
$text='<a href="http://www.google.com/">gfsdfgsdgdsfgsdgsfd</a> <a
href="http://www.orkut.com/">';
[/PHP]
it could find both of them! it think the reason of this problem is
multiline.
therefore i have a questoin. is regex functions in php can support
multiline texts?
many thanks
(sorry for my bad english)



Closed Thread