in reply to Link regex
#!/usr/bin/perl -w use strict; #set up the test data my @potential_links = ('[url|desc|target]','[www.test.com|test page]', +'[www.test.com|test page|new]'); #using the test data foreach(@potential_links){ #strip out the braces $_ =~ s/\[|\]//g; #split the remaining string represented by $_ on the pipe my($url, $desc, $target) = split /\|/; #ternary to test if $target was set if not print the non-target vers +ion. ($target) ? print qq*<a href="$url" target="$target">$desc</a>\n* : +print qq*<a href="$url">$desc</a>\n* ; } exit;
|
|---|