IOrdy has asked for the wisdom of the Perl Monks concerning the following question:
# ... my %taglist_complex = ( 'email' => "<a href='mailto:$1'>$2</a>", 'url' => "<a href='$1'>$2</a>", 'img' => "<img src='$1' alt='$2' />" ); my %taglist_simple = ( 'b' => '<b>$1</b>', 'i' => '<i>$1</i>', 'u' => '<u>$1</u>', 'url' => '<a href=\'$1\'>$1</a>', 'img' => '<img src=\'$1\' alt=\'$1\' />' ); # Process Complex Tags -> [url="http://www.foo.bar.com"]foobar[/ur +l] while (my ($tag, $regex) = each %taglist_complex) { $post =~ s/\[\s*$tag\s*=\s*['"]?([\w\W][^\]]*?)['"]?\](.[^\[|\ +]]*?)\[\s*\/\s*$tag\s*\]/$regex/gi; } # Process Simple Tags -> [url]http://www.foo.bar.com[/url] while (my ($tag, $regex) = each %taglist_simple) { $post =~ s/\[\s*$tag\s*\](.[^\[|\]]*?)\[\s*\/\s*$tag\s*\]/$reg +ex/gi; } #...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Drop in regex replacements?
by Ovid (Cardinal) on Sep 09, 2002 at 15:02 UTC | |
by IOrdy (Friar) on Sep 09, 2002 at 16:41 UTC | |
|
Re: Drop in regex replacements?
by Joost (Canon) on Sep 09, 2002 at 14:50 UTC | |
by IOrdy (Friar) on Sep 09, 2002 at 14:58 UTC | |
by Joost (Canon) on Sep 09, 2002 at 15:07 UTC | |
|
Re: Drop in regex replacements?
by zigdon (Deacon) on Sep 09, 2002 at 14:31 UTC | |
by IOrdy (Friar) on Sep 09, 2002 at 14:42 UTC | |
|
Re: Drop in regex replacements?
by Util (Priest) on Sep 09, 2002 at 19:43 UTC |