in reply to Re: Re: Re: Re: Re: Re: User Code
in thread User Code

Good point! :)

I also realised that it will only work if you type http:// or https://. It's nice to be able to leave out the http:// bit if you want it to default to http://

So maybe you would have to do two regexes:
$text =~ s#\[https://([^\|]+)\|([^\]]+)\]#<a href="https://$1">$2</a> +#g; $text =~ s#\[(http://)?([^\|]+)\|([^\]]+)\]#<a href="http://$2">$3</a +>#g
Is there a simpler way of doing that?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Re: User Code
by duct_tape (Hermit) on Dec 11, 2000 at 19:40 UTC
    You could combine both of those regexps into one by doing something like this: s#\[(?:http(s)?://)?([^\|]+)\|([^\]]+)\]#<a href="http$1://$2">$3</a>#g;

    - Brad
      Nice one! Thanks!

      I didn't start this node and I think I managed to divert the topic somewhat, but have definitely been helped.