Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
-
ddragas
- Forum Contributor
- Posts: 445
- Joined: Sun Apr 18, 2004 4:01 pm
Post
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>";
-
superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Post
by superdezign »
You have this a few times:
It should be this:
Outside of the character class, it's just a character I believe.
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
Regex patterns?

Regex.

-
ddragas
- Forum Contributor
- Posts: 445
- Joined: Sun Apr 18, 2004 4:01 pm
Post
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
-
ddragas
- Forum Contributor
- Posts: 445
- Joined: Sun Apr 18, 2004 4:01 pm
Post
by ddragas »
thank you
regards