473,473 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Quick perl question 2

I don't want to pester, but i have just one more follow up to this script
I'm writing:

The files I'm pulling has bylines in them. If I do this:

($byline, $title) = $_ =~ /By\s?(.*)<br><br>([A-Za-z
]+)<br><br>.*$/;
#($firstgraph) = $_ =~ /<p>(.*)<br><br>([A-Za-z ]+)<br><br>.*$/;
print "By: $byline\n\n";
print "Title: $title\n";

Then it will print out the Byline and title. Bingo, no problem. But, If I do
this:

$_ =~ s/By.*<br><br>.*<br><br>/g;

It will erase everthing up UNTIL the last two <br> tags -- which eliminates
the whole story except the last paragraph! How do I tell to only go through
the first and second sets of <br> tags?
(FYI, i'm trying to remove the byline and title so I can do nifty things,
like print out the first paragraph on an index page and correctly format the
byline later.
Jul 19 '05 #1
1 1600
dw

"jack" <ja**@raxo.net> wrote in message news:BB6E997A.373%ja**@raxo.net...
I don't want to pester, but i have just one more follow up to this script
I'm writing:

The files I'm pulling has bylines in them. If I do this:

($byline, $title) = $_ =~ /By\s?(.*)<br><br>([A-Za-z
]+)<br><br>.*$/;
#($firstgraph) = $_ =~ /<p>(.*)<br><br>([A-Za-z ]+)<br><br>.*$/;
print "By: $byline\n\n";
print "Title: $title\n";

Then it will print out the Byline and title. Bingo, no problem. But, If I do this:

$_ =~ s/By.*<br><br>.*<br><br>/g;

It will erase everthing up UNTIL the last two <br> tags -- which eliminates the whole story except the last paragraph! How do I tell to only go through the first and second sets of <br> tags?
(FYI, i'm trying to remove the byline and title so I can do nifty things,
like print out the first paragraph on an index page and correctly format the byline later.


Tell the .* not to be greedy by adding a ?
$_ =~ s/By.*?<br><br>.*?<br><br>/g;

However, this reg exp is incomplete since you don't specify what the found
text should be replaced with....
And, I'm not quite sure why you have the /g on there either.


Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.