Anybody know how this Web site abbreviates/shortens the URL links posted in these threads? I'd like to incorporate this feature into http://www.usedflutes.com and http://www.usedviolins.com for the often very long URL links posted there.
Many thanks in advance,
In general you could do this:
Though this method of identifying anchors in HTML is very specific and will not match all valid occurances. You should use HTML::TokeParser for this if possible.
$text =~ s|(<a href="[^"]*?">)(.*?)(</a>)|$1 . (length $2 > 20 ? substr($2, 0, 16) . '...' : $2) . $3|eg;
Wow! Thanks Jeff. Unfortunately, this is quite a bit "over my head," so I have some homework to do to see if I can figure out how to integrate it into the MySQL script.
Thanks again Jeff for the help, :-)
OK - I'm not sure how to do this...
I did read about TokeParser from the link you sent as well as a general search on Google for other users of it ( for example, http://wdvl.internet.com/Authoring/L...okeParser.html ). However, I'm still not clear on how to integrate/modify it into the existing script http://usedflutes.com/MySQL_script.txt ( $val = the URL link ).
BTW, somebody recently posted a very long URL on http://www.usedflutes.com which is a good example of what I'm trying to abbreviate ( http://search.freefind.com/find.html...email@example.com )
It looks like this forum abbreviates URLs formatted as 35 characters -> ... -> 15 characters. Something similar to this would be great.
Thanks again Jeff for any more help on this you can provide,
Last edited by bobafifi; 04-02-2003 at 09:16 AM.
Got it! :-)
(see "The Mad Hatter" http://www.perlmonks.org)
Last edited by bobafifi; 04-06-2003 at 01:00 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)