Solved

simple question perl coding

Posted on 2008-06-09
4
186 Views
Last Modified: 2013-12-25
this source :
<br><a href='http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php' class='link_small'>http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php</a></td></tr>

how to crop in perl

the one statred from class='link_small'> and ended with </a>
resulted to this :
http://www.oracle.com/technology/obe/11gr1_db/appdev/php/files/errors.php

i have tried using this code:

$link =~ m/class=\'link_small\'?>http:\/\/(.+?)\<\/a>/g

is that correct? or any accurate coding?
0
Comment
Question by:abangbatax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 50 total points
ID: 21744807
I'm not sure what you are asking?  The code you have above does not include the "http://" in what is captured.  If you want to include that:
    m/class=\'link_small\'?>(http:\/\/.+?)\<\/a>/g

Also, the /g option is for a global match.  Unless this is going to appear more than once, you don't need that option.

A generally more reliable way to get info from HTML files is with an HTML parser.  In some cases a simple regex will work, but there are cases that will break the regex...

0
 

Author Comment

by:abangbatax
ID: 21745337
/g = global match?
do i need it?

i am scripting a web link grabber...  based on keyword

should i add /g ?
0
 
LVL 39

Expert Comment

by:Adam314
ID: 21746040
That depends on what you want.  If the content (what is in $link) can have the desired text appear multiple times, and you want to get all of them, then yes - use the /g.  
0
 

Author Closing Comment

by:abangbatax
ID: 31465461
thank you for your help!
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question