Click to See Complete Forum and Search --> : Short URL?


bobafifi
03-11-2003, 09:45 AM
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,

-Bob

jeffmott
03-11-2003, 02:33 PM
In general you could do this:
$text =~ s|(<a href="[^"]*?">)(.*?)(</a>)|$1 . (length $2 > 20 ? substr($2, 0, 16) . '...' : $2) . $3|eg;Though this method of identifying anchors in HTML is very specific and will not match all valid occurances. You should use HTML::TokeParser (http://www.perldoc.com/perl5.8.0/lib/HTML/TokeParser.html) for this if possible.

bobafifi
03-11-2003, 08:50 PM
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, :-)

-Bob

bobafifi
04-02-2003, 08:01 AM
Hi Jeff,
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/Languages/Perl/PerlfortheWeb/TokeParser.html ). However, I'm still not clear on how to integrate/modify it into the existing script http://usedflutes.com/MySQL_script.txt ( $val[5] = 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?id=6901309&pageid=r&mode=ALL&n=0&query=flute_gal@msn.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,

-Bob

bobafifi
04-05-2003, 09:11 PM
Got it! :-)

(see "The Mad Hatter" http://www.perlmonks.org)

Thanks again,

-Bob