I have a regular expression that is suppose to truncate long URLs at 50
characters and add "...", but can't figure out why it is not working with a
particular URL.

Here is the regex:

$url =~s#>((?:http\|ftp\|file)://.{50}).+</a>#>$1...</a>#g;

And here is the problem URL:

<a
href="http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_
main.html?name=Toles&amp;date=09012006">http://www.washingtonpost.com/wp-srv
/opinions/cartoonsandvideos/toles_main.html?name=Toles&amp;date=09012006</a>

Here is what the regex should return:

<a
href="http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_
main.html?name=Toles&amp;date=09012006">http://www.washingtonpost.com/wp-srv
/opinions/cartoonsand...</a>

Interestingly, the regex works fine on this modified version of the URL:

http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_main.h
tml?name=Toles

I think the digits might have something to do with it, but not sure.

Any thoughts?

Thanks!

Chris

--------------------------

Chris Schults
Web Production Manager
Grist Magazine
710 Second Avenue, Suite 860
Seattle, WA  98104
Phone: 206-876-2020, ext. 204
Fax: 253-423-6487
<http://www.grist.org>

To sign up for Grist by email, the world's top environmental news served up
with a sense of humor, click here <http://www.grist.org/signup/> or send a
blank email message to <[EMAIL PROTECTED]> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to