in reply to Regular Expressions: Call for Examples
Next, the regexes:my %TAG = ( ftp => 'ftp://', http => 'http://', https => 'https://', kobe => 'http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?filet +ype=+distribution+name+or+description&j&case=clike&search=', kobes => 'http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?filet +ype=+distribution+name+or+description&j&case=clike&search=', cpan => 'http://search.cpan.org/search?mode=module&query=', isbn => 'http://shop.barnesandnoble.com/booksearch/isbnInquiry.a +sp?isbn=', google => 'http://www.google.com/search?q=', lucky => 'http://www.google.com/search?btnI=I&q=', jargon => 'http://www.science.uva.nl/cng/search/htsearch.CGI?restr +ict=%2F%7Emes%2F&jargon%2Fwords=', id => '/index.pl?node_id=', pad => '/index.pl?node_id=108949&user=', DEFAULT => '/index.pl?node=', );
The 3 regexes have to be executed in that order. Maybe they could be combined into one regex, but this worked for me. :)# takes care of [tag://target|alt] $chunk =~ s/\[(\w+):\/\/(.*?)\|([^\]]+)\]/<a href="$TAG{$1}$2">$3<\/a> +/g; # takes care of [tag://target] $chunk =~ s/\[(\w+):\/\/([^\]]+)\]/<a href="$TAG{$1}$2">$2<\/a>/g; # takes care of [target] $chunk =~ s/\[([^\]]+)\]/<a href="$TAG{DEFAULT}$1">$1<\/a>/g;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (jeffa) Re: Regular Expressions: Call for Examples
by jryan (Vicar) on Jul 22, 2002 at 01:56 UTC |