MoldNet Root wrote:
>
> hello,
>
> sorry if this is an off-topic, but i'd
> like to know which is the best regex to much
> an URL...
>
> best regards,
> mitica
Here's more then what you want, and the authors name is still here.
Golf any one?
__________________________________
$urls = '(' . join( '|', qw( http gopher wais file ftp https
) ) . ')';
$ltrs = '\w';
$gunk = '/#~:.?+=&%@!\-';
$punc = '.;?/-';
$any = "${ltrs}${gunk}${punc}";
s{ # make links work -- Tom Christiansen
\b # start at a word boundry
( # begin $1
${urls} : # need resourde and a colon
[$any] +? # followed by one or more of any
# valid char, but be conservative
# and take only whay you need to...
) # end $1
(?= # a look-ahead, non-consumptive asseration
[$punc]* # Either 1 or more punctuation
[^$any] # Followed by a anon-url char
| \Z # or else the end of the line.
)
} {<A HREF="$1">$1</A>}igox;