in reply to Converting custom mark-up to HTML

It's easier to get the opening and closing tags with the enclosed text in one go instead:
#!/usr/bin/perl use strict; use warnings; $/ = undef; my $text = <DATA>; $text =~ s!\[color=([^\]]+)\](.*?)\[/color\]!<font color="$1">$2</font +>!gi; $text =~ s!\[image=([^\]]+)\]!<img src="$1">!gi; $text =~ s!\[link=([^\]]+)\](.*?)\[/link\]!<a href="$1">$2</a>!gi; print $text; __DATA__ [color=#0000ff]Blue text[/color] with an image: [image=var.jpg] And a link to Google: [link=http://www.google.com]Google[/link].
This gives the following output (which I think is what you want):
<font color="#0000ff">Blue text</font> with an image: <img src="var.jp +g"> And a link to Google: <a href="http://www.google.com">Google</a>.

Arjen

Replies are listed 'Best First'.
Re: Re: Converting custom mark-up to HTML
by bkiahg (Pilgrim) on Apr 19, 2004 at 17:52 UTC
    Thats exactly what I'm looking for. Having a hard time getting regular expressions. Thank you aragorn!