473,231 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

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 1551
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.