CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
String Matching between TWO identifiers

 



l4teral
User

Jul 13, 2010, 1:13 PM

Post #1 of 2 (338 views)
String Matching between TWO identifiers Can't Post

Hey everyone,


I am trying to parse an html file with a perl script. I want to be able to get the exact name of all jpg/gif/png images within the html file.

string matching such as

Code
/\.jpg/i

would obviously match all .jpg instances, but I want to be able to save the entire URL to a variable.


basically - I want to be able to string match to say-

Code
match between the term /http/i  and /\.jpg/i

Is this possible?


(This post was edited by l4teral on Jul 13, 2010, 1:15 PM)


BillKSmith
Veteran

Jul 13, 2010, 3:15 PM

Post #2 of 2 (331 views)
Re: [l4teral] String Matching between TWO identifiers [In reply to] Can't Post

The short answer is "yes", especially if you can tolerate some false positive matches. HTML is sufficiently complicated that it probably easier to find a module on CPAN than it is to get it exactly right yourself. If you insist on do-it-yourself, I would start with


Code
  

(my $url) = $html =~ /(html.+\.(?:jpg|gif|png))/i; # untried



Replace .+ with better descriptions until the error rate is sufficiently low.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives