Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

parenthesis as memory or substitution?

Posted on 2003-10-22
4
Medium Priority
?
206 Views
Last Modified: 2012-05-04
Please bear with me. I'm a Perl novice.

I have some HTML code being read in from a file with includes this image tag (actually several of them):

<Img Src="/content/Images/Blobs3/bra1master.gif" Width="81" Height="6" Border="0"></Td>

Out of this code, all that I want is the number 81 from the width--nothing else.

How would I go about this?
If I'm not giving enough information let me know, I'll try to be clearer.

0
Comment
Question by:jdixon
[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
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 200 total points
ID: 9601365
$_ = '<Img Src="/content/Images/Blobs3/bra1master.gif" Width="81" Height="6" Border=""0"></Td>';
($width) = /Width="(\d+)"/;
0
 
LVL 8

Accepted Solution

by:
inq123 earned 1000 total points
ID: 9601841
Hi jdixon,

if your img tag is inside normal html file and it's always this syntax, then you probably want to use the whole tag as regex pattern as ozo's solution will get too much noise when a full html file is parsed.  Something like below would work:

while(<IN>) # reading the html file
{
  while(m|<Img\s*Src\s*=\s*"/content/Images/Blobs3/bra1master.gif".*?Width="(\d+)"[^>]*>\s*</Td>|ig)
  {
    print "width is $1\n";
  }
}

This'll be pretty safe since it deals with full html file, it deals with more than one img tag on one line, and it allows for some variations on the img tag.

Cheers!
0
 

Author Comment

by:jdixon
ID: 9602167
Thanks to the both of you! You guys are great not to mention fast.
0
 
LVL 8

Expert Comment

by:inq123
ID: 9602244
You're welcome!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

722 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