Gossamer Forum
Skip to Content



Home : Products : Gossamer Links : Development, Plugins and Globals :

Plugin to show shorter url / regex problem

Quote Reply
Plugin to show shorter url / regex problem
I have tested the regex with kommodo rx toolkit and it seems everything ok, but when i use it in Links or in the komodo edbugger, i got no values for $1, $2 and so on.

Code:


sub {
my $tags = shift;
my $tmp = "http://www.sub.domaine.com/dirs/file";#$tags->{URL};
$tmp =~ m/^(http:\/\/) ( ([a-z0-9\-]+ [\.]) +?) ([a-z0-9\-]+ [\.]) ([a-z]+) (\/) (.*)/ ;
$tmp = "$1$2$4$5$6";
if ($7 !='') {
$tmp .= "...";
}
return $tmp;
}
Has someone a clue, whatīs wrong with it?
Quote Reply
Re: [Robert] Plugin to show shorter url / regex problem In reply to
Whats the aim of the regex? Why slice it up? Wouldn't you be better using substr() to do this? And then length() to find out if its longer than expected, so you can put the ... at the end of it.

Thats how I would do it anyway :)

Cheers

Andy (mod)
andy@ultranerds.com


Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Custom Toolbar for IE and Firefox! - Compare our different Plugin packages *new*
Free CSS Templates
Quote Reply
Re: [Andy] Plugin to show shorter url / regex problem In reply to
Thank you. Length is not the rigth one, because i want to show the whole url, have fix it. Spaces are not allowed, i have learned ;)
Maybe a shorter one would be enough to ask for the first slash. But finally i have understand more of this regex and thatīs worth the two hours ;-)