[prev in list] [next in list] [prev in thread] [next in thread]
List: cgi-list
Subject: RE: [CGI] how do i extract everything between <TABLE> and </TABLE>from a variable?
From: "Mark.G.Franz" <MARK.G.FRANZ () cpmx ! saic ! com>
Date: 1998-02-26 14:49:05
[Download RAW message or body]
Just a comment, this list could use some more teachers, I often see a
answer without a thorough explanation, I find that being able to read
whats happening makes the script understandable.
Mark
> -----Original Message-----
> From: Jonathan Peterson [SMTP:jon@amxdigital.com]
> Sent: Thursday, February 26, 1998 1:36 AM
> To: cgi-list@jann.com
> Subject: RE: [CGI] how do i extract everything between <TABLE>
> and </TABLE>from a variable?
>
> At 02:41 PM 2/26/98 +1300, James McNeill wrote:
> >Something like this should work:
> >
> >my ($table) = $a =~ m|<table>(.*?)</table>|si;
>
> Since it's not obvious:
>
> 1. The variable $table needs to be in brackets, so that it is a list
> context. If it is a list context, perl returns the text captured by
> the
> brackets, otherwise it returns the number of matches found.
>
> 2. .*? is like .* but the ? makes it non-greedy. This basically means
> it
> will matches the shortest valid string. This would be important if
> there
> were multiple table tags in the text.
>
> 3. There are two modifiers at the end, s and i. i simply makes the
> match
> case insensitive. The s treats the text as a single line, essentially
> ignoring linebreaks. This is needed, because .* doesn't normally match
> linebreaks. If you need to slurp up multiple lines in a regexp, the s
> modifier is very handy.
>
> Sorry for being such a teacher! (Esp. if I got something wrong...)
>
> --------
> Jon Peterson jon@amxdigital.com +44 (0)171 613 5300
> Internet Developer
>
>
> Test tube babies shouldn't throw stones.
> -----------------------------------------------------------------
> To unsubscribe, mailto:majordomo@jann.com with "UNSUBSCRIBE cgi-list"
> in the message body.
> To contact a person at the CGI list, mailto:owner-cgi-list@jann.com
>
> The CGI Tips & Tricks website (and archive of the list) is located
> at http://www.jann.com/Perl/
>
> cgi-list is hosted by Wizards of the Web (http://wizweb.com).
> -----------------------------------------------------------------
-----------------------------------------------------------------
To unsubscribe, mailto:majordomo@jann.com with "UNSUBSCRIBE cgi-list"
in the message body.
To contact a person at the CGI list, mailto:owner-cgi-list@jann.com
The CGI Tips & Tricks website (and archive of the list) is located
at http://www.jann.com/Perl/
cgi-list is hosted by Wizards of the Web (http://wizweb.com).
-----------------------------------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic