in reply to (jeffa) Re: Monks' Expression
in thread Monks' Expression

Instead of trying to do everything with a single regular expression, consider breaking it up into two.

$str =~ s/\[id=(\d+)\]/<a href='...$1'>/g; $str =~ s/\[\/id\]/<\/a>/g; print $str;

This will deal more gracefully with links that span multiple lines (which often happens when people write in a auto-wrapping editor.)