Re: preg_match(_all) confusion



Zacariaz wrote:
Ok, so I usually just look at the manual, but this time I simply don't
understand the content. It's embaresing really.

Anyway, the problem is real simple. I grap some source:

#
$ch = curl_init("****");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
#

This works fine, though I'm not sure it the best way of doing it, but
for now that's not important.

In this source I know there is some very specific html tags, which I
need to get the contents of. The tags are:

<TD COLSPAN="5">content</TD>
<TD ALIGN="RIGHT" COLSPAN="2">content</TD>

I figure I need to use preg_match or preg_match_all, but I'll be
damned if I understand how they work.


Well, I hope you will spend a few minutes on a desperate retard.


Regards

hi Zacariaz,

I took me a good part of a year to under stand simple syntax of regular expressions, I recommend that you get your self a copy of "Mastering Regular Expressions" http://oreilly.com/ .

you need to something like this

"/\<TD COLSPAN=\"5\">([^\<])\<\/TD\>/"
"/<TD ALIGN=\"RIGHT\" COLSPAN=\"2\">([^\<]+)\<\/TD\>/"

I would suggest that you use preg_match_all.

I hope that gets your started.

I'm sure if I made any mistakes the guys here will jump in with corrections .


regards
trookat

.



Relevant Pages

  • Re: Shud not search HTML tags
    ... The Microsoft .Net SDK has a great section on Regular Expressions as well: ... >>> page there should be HTML tags but should not be Highlighted. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: String Parsing : Best Methods : VBA
    ... Use Regular Expressions in Microsoft Visual Basic 6.0 ... Regards, ... > each string within the Variant, and use Instr, Mid$ ...
    (microsoft.public.excel.programming)
  • Re: A Reg-exp compendium of frequently occuring matches?
    ... MD> stripping out HTML tags, validating IP addresses, etc. ... Both of those are extremely poor uses for regular expressions. ... -- cwilbur at chromatico dot net ...
    (comp.lang.perl.misc)
  • Re: DateTimeFormatInfo, Culture and custom formatting
    ... > Regards, Jakob. ... Should I go for regular expressions or is there ... >> George Ionescu ...
    (microsoft.public.dotnet.framework)
  • Re: Specific E-Mail Validation Script
    ... Many Thanks in advanced, Regards, Jason ... You /really/ are best not trying to validate an email address with ... regular expressions. ...
    (comp.lang.javascript)