Page 1 of 1

regex paterns

Posted: Mon Jul 02, 2007 12:45 pm
by ddragas
this is main pattern into web page (html)

Code: Select all

<td id=type>Type_is_important</td><td>|</td><td><a href="link_is_not_important" target=a>Description_of_link_is_important</a></td>
Now what I want to acomplish is to check if "Type" is something than return link, and if Description of link is something return link.

If someone can check for me if I've putted good patterns


Code: Select all

$glavni_pattern = "<td id=type>\"^[\"]*\"</td><td>|</td><td><a href=\"^[\"]*\" target=a>\"^[\"]*\"</a></td>";
$pattern_za_link= "HREF=\"[^\"]*\"";
$pattern_za_opis= "\"^[\"]*\"</a>";
$patern_za_vrstu = "type>\"^[\"]*\"</td>";

Posted: Mon Jul 02, 2007 2:10 pm
by superdezign
You have this a few times:

Code: Select all

^[...]

It should be this:

Code: Select all

[^...]
Outside of the character class, it's just a character I believe.

Posted: Tue Jul 03, 2007 12:02 am
by feyd
Regex patterns? :arrow: Regex. :roll:

Posted: Tue Jul 03, 2007 2:54 pm
by ddragas
thank you for reply

one more thing

what regex should I use to get all data between "<tr" and "</tr>"

tried to use "/<tr[^\"]*\<\/tr>/" but with no sucsess

using preg_match_all

here is all code

Code: Select all

$url = file_get_contents("some_url");

preg_match_all( "/<tr[^\"]*\<\/tr>/" ,  $url, $red, PREG_SET_ORDER);

print_r ($red);
thank you

regards

Posted: Tue Jul 03, 2007 2:57 pm
by John Cartwright

Code: Select all

preg_match_all( "/<tr>.*?<\/tr>/i" ... );
Keep things simple :wink:

Posted: Tue Jul 03, 2007 3:04 pm
by ddragas
thank you

regards