Solved

simple question perl coding

Posted on 2008-06-09
4
183 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
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
Adam314 earned 50 total points
Comment Utility
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
Comment Utility
/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
Comment Utility
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
Comment Utility
thank you for your help!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to count occurrences of each item in an array.

762 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now