Good day,

The problem here is with the .* expression, which matches any character,
including > .  The regex is "greedy" and will try and match as much as it
possibly can.

What you could do is change it so that it doesn't match > .  Then, the >
will be matched later in the expression,, as you want.

So, [^>]* instead of .* should do it, I believe.

============================
Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


-----Original Message-----
From: Wakan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 19, 2001 9:08 AM
To: [EMAIL PROTECTED]
Subject: [PHP] regular expression


Hi,
Can you help me on this simple regexp?
I've this string:
$testata = "<tr bgcolor=\"#FF9900\" valign=\"middle\"><td colspan=\"2\"
align=\"center\" height=\"11\"><div align=\"left\" class=\"titoliblu\">NEWS
A ROTAZIONE</div></td><td class=\"titolipiccolibianchi\" align=\"center\"
height=\"11\" width=\"10%\">cancella</td></tr>";

and this eregi:
eregi("^<tr(.*)>(.*)</tr>$",$header,$regs);

In this way I'd like to obtain the properties of the row
(ie: bgcolor=\"#FF9900\" valign=\"middle\")
and all the columns in the row (the content of each pair <td>...</td>).

I'm expecting to have this:
in $reg[1]: bgcolor=\"#FF9900\" valign=\"middle\"
in $reg[2]: <td colspan=\"2\" align=\"center\" height=\"11\"><div
align=\"left\" class=\"titoliblu\">NEWS A ROTAZIONE</div></td><td
class=\"titolipiccolibianchi\" align=\"center\" height=\"11\"
width=\"10%\">cancella</td>

Instead I''ve this:
$reg[1]: bgcolor=\"#FF9900\" valign=\"middle\"><td colspan=\"2\"
align=\"center\" height=\"11\"><div align=\"left\" class=\"titoliblu\">NEWS
A ROTAZIONE</div></td><td class=\"titolipiccolibianchi\" align=\"center\"
height=\"11\" width=\"10%\">cancella</td

ie the last ">" was found, but I'd like the FIRST one!!

Can someone give me a solution?
Thanks, Carlo


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to