Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Wrong Pattern for match_count function
May 9, 2005, 9:25 pm
rate this thread
Hi all there,
Sorry for this newbee question but how comes that the following
pattern: $r = "%<td valign=top><a href=\"([^>]+?)\"(.*?)>%";
does not return any result, while the pattern:
$r = "%<a href=\"([^>]+?)\"(.*?)>%";
returns me results, but too many (that's why I wanted to use the first
pattern, without any luck).
Called function: $match_count = preg_match_all ($r, $pdata, $items);
Example of $pdata:
<td width=80 align=center valign=top><a href="<link that should not be
grabbed by the pattern>" id=r><img src=image.jpg width=66 height=79
alt="" border=1><br><font size=-2>Bla Bla text</font></a></td><td
valign=top><a href="<link that should be grabbed by the pattern>"
id=r>Bla bla text</a><br>
Can Anyone help, please?
Re: Wrong Pattern for match_count function
Stefan Heinrichsen wrote:
Thanks for your reply Stefan,
How should it not? Sorry, I am probably wrong, but I am not familiar
with regexp and reading the rules...does not help me, in this case
I need to distinguish this string:
"<td valign=top><a href...." by this one
"<td width=80 align=center valign=top><a href...."
I need to match the first and not the second.
You may try the correct
BTW, this does not match any pattern at all. (why? shouldn't it return
any "<td...><a href...>" pattern? it's not what I want, however....)
If you could clarify. Many thanks.