Connecting Tech Pros Worldwide Help | Site Map

regex and multiline problem

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:16 PM
sinasalek
Guest
 
Posts: n/a
Default regex and multiline problem

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)



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.