[PHP] Real world regex

2002-03-04 Thread Craig Westerman

I'm trying to understand how to write a regex when the only pattern is table
tags.

For one I need to figure out how to match the opening table tag of the 4th
html table on a page.


For another I need to get the 3rd opening table row tr tag after the 7th
opening table tag.


Thanks

Craig 
[EMAIL PROTECTED]



Re: [PHP] Real world regex

2002-03-04 Thread Bas Jobsen

 For another I need to get the 3rd opening table row tr tag after the 7th
 opening table tag.

not tested:
(table[^]+.*){6}(table[^]+)([ ]*)(tr[^]*)(.*){2}(tr[^]*)(.*)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Real world regex

2002-03-04 Thread Craig Westerman

-Original Message-
From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 8:55 AM
To: Craig Westerman; php-general-list
Subject: Re: [PHP] Real world regex

 For another I need to get the 3rd opening table row tr tag after the 7th
 opening table tag.

not tested:
(table[^]+.*){6}(table[^]+)([ ]*)(tr[^]*)(.*){2}(tr[^]*)(.*)

-


Bas,

Thanks for the reply. I can easily grab this test page
http://www.gold-forum.com/table.html using this script. (shown below)
http://www.gold-forum.com/grab2.php

When I try replacing $GrabStart = body; with your $GrabStart =
(table[^]+.*){6}(table[^]+)([ ]*)(tr[^]*)(.*){2}(tr[^]*)(.*);
I get errors.

If you have time, can you show me what I need for:

$GrabStart = ???; //3rd opening table row tr tag after the 7th opening
table tag
$GrabEnd = ???; //3rd closing table row tr tag after the 7th closing
table tag

Thanks

Craig 
[EMAIL PROTECTED]


code start-
html
head
titleGrab 2 Example/title

/head
body

?

$GrabURL = http://www.gold-forum.com/table.html;;
$GrabStart = body; //need 3rd opening table row tr tag after the 7th
opening table tag
$GrabEnd = /body; //need 3rd closing table row tr tag after the 7th
closing table tag

$file = fopen($GrabURL, r);
$rf = fread($file, 20);
$grab = eregi($GrabStart(.*)$GrabEnd, $rf, $printing);
fclose($file);
echo $printing[1];
?

/body
/html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php