Garayed.com  

Go Back   Garayed.com > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-14-2006, 06:34 PM
Mike Zhang
 
Posts: n/a
Default Regular Expression Problem

I got stuck with regular expression problem.
What i want to do is to extract hello world if 'message' is found in the
same row.
I have gotten until //A. but somehow //B doesn't work.

<?php
$string = '<html>
<body>
<table>
<tr>
<td class="bg-grey-m">
<table cellpadding="12">
<tr><td>message</td><td><i>hello world</i></td></tr>
<tr><td>tel</td><td><i>111-111-555</i></td></tr>
</table>
</td>
</tr>
</table>
</body>';
//A
//preg_match_all("/<td [^>]*class=\"bg-grey-m\">[^<]+<table([^>]*)>/iU",
$string, $matches);

//B
preg_match_all("/<td
[^>]*class=\"bg-grey-m\">[^<]+<table[^>]*>.*message.*<i>(.*)<\/i>.*<\/table>
..*/iU", $string, $matches);

foreach($matches[1] as $link)
{
echo "<li>$link</li>\n";
}


?>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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



All times are GMT. The time now is 09:07 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.