PDA

View Full Version : Help with regular expressions (preg match)...


pass124
11-10-2005, 12:45 AM
Hi,
I'm learning how to use preg match right now for the past two months, I've been using regular-expressions.info.

I am hoping some of you guys may know where I can learn regular expressions ALOT better, making things alot more precise, and hopefully works with PHP and PREG_MATCH.

I have html files right now, that in each of these hundreds of files, there is a table, and inside that table there is a line or several lines of information I Want to retrieve using preg match.

<?
preg_match("/<td><tr>(.*)<\/tr><\/tr>/i",$matches);
?>

This does not work the way I want it to, it keeps going from the FIRST <td><tr> found until the LAST </td></tr> found.

How do I make it go from the first <td><tr> found until the FIRST </td></tr> is come across ????

I appreciate any help, I want to LEARN this stuff better, and I learn from examples and websites, but I learned everything I could from regular-expressions.info.....

Thanks in advance.

yktan
11-10-2005, 04:12 AM
Hi pass124,

Could you try preg_match_all instead?

pass124
11-10-2005, 06:26 AM
nope, rules for preg match and preg match all are identical.

If i did preg match all, it would return the exact same thing because (.*) is not limited until the LAST </tr></td> is found.