473,473 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Wrong Pattern for match_count function

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?

Thanks.
Fabian

Jul 17 '05 #1
4 1557
Am Mo 09.05.05 um 16:25 CEST schrieb "Fabian" <ne******@hotmail.com>:
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[...]

Example of $pdata:
<td width=80 align=center valign=top><a href="[...]

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How should this match against "<td valign=top>"? You may try the correct
<td> line or something like (untested)
%<td[^>]*><a href=\"([^>]+?)\"(.*?)>% as pattern.

stefan
Jul 17 '05 #2

Stefan Heinrichsen wrote:
Am Mo 09.05.05 um 16:25 CEST schrieb "Fabian" <ne******@hotmail.com>:
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[...]

Example of $pdata:
<td width=80 align=center valign=top><a href="[...] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How should this match against "<td valign=top>"?


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 <td> line or something like (untested)
%<td[^>]*><a href=\"([^>]+?)\"(.*?)>% as pattern.


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.
Cheers,
Fabian

Jul 17 '05 #3
Am Mo 09.05.05 um 23:23 CEST schrieb "Fabian" <ne******@hotmail.com>:

Stefan Heinrichsen wrote:
Am Mo 09.05.05 um 16:25 CEST schrieb "Fabian"
<ne******@hotmail.com>:
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[...]

Example of $pdata:
<td width=80 align=center valign=top><a href="[...]

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
How should this match against "<td valign=top>"?


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.


Oh sorry my fault. I don't read you $pdata exactly. Is $pdata a exactly
copy or is it possible that there are any whitespace or somethingelse
you may forgot?

stefan
Jul 17 '05 #4

Stefan Heinrichsen wrote:

Oh sorry my fault. I don't read you $pdata exactly. Is $pdata a exactly copy or is it possible that there are any whitespace or somethingelse
you may forgot?


It should be the exact copy of what it should be, however I hope to be
able to add any whitespace information: "\s+" if this would be the
case.

Thanks for your help.

Fabian

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fabian | last post by:
Hi all there, I have already tried asking for help a couple of days ago. I try to rephrase better my problem: I need to grab a webpage that looks like this: <td width=80 align=center...
17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
2
by: kk | last post by:
I have this portion in my schema definition: <xsd:simpleType name="MyTimeType"> <xsd:restriction base="xsd:dateTime"> <xsd:pattern value="\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}-Z"/>...
5
by: Ronald Fischer | last post by:
I have a server-side JavaScript function returning a string. I would like to test wheather or not the string contains the following pattern: - an equal sign, - followed by one or more characters...
11
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns....
2
by: Larry Menard | last post by:
Folks, I'm writing an SQL UDF to replace DB2's LIKE (which has some nasty limitations regarding concatenation), and I've reached a problem that I can't figure out. It must be a coding or logic...
11
by: td0g03 | last post by:
Hello, I just have a few questions. The first one be how would you print a pattern. I could use the if else, but I remember my teacher talking about something like for(i=1;i<=size;i) ...
4
by: dustin | last post by:
I've been hacking away on this PEP for a while, and there has been some related discussion on python-dev that went into the PEP: ...
8
by: Raistlin Majere | last post by:
at test.php is... <form action = "test1.php" method = "POST"> <p> <b>Interests:</b> <br> <input type = "Checkbox" name = "interests" value = "politics">Politics <input type = "Checkbox" name...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.