in reply to Re: Monks' Expression
in thread Monks' Expression

$text =~ s/\[(id=.*?)](.*?)\[\/id]/<a href=\"$targetURL\1\">\2<\/a>/gs;

Replies are listed 'Best First'.
Re: Re: Re: Monks' Expression
by repson (Chaplain) on Jan 22, 2001 at 04:18 UTC
    $text =~ s#\[(id=[^\]]*)]([^\[]*)\[/id]#<a href="$targetURL$1">$2</a>#gs;
      $text =~ s#\[(id=[^]]*)]([^[]*)\[/id]#<a href="$targetURL$1">$2</a>#g;
        Hmm. Nothing in there about HTML-entitizing either the href or the body text. You probably knew that, but for the onlookers, the normal HTML quoting rules must apply here.

        -- Randal L. Schwartz, Perl hacker

Re: Re: Re: Monks' Expression
by sierrathedog04 (Hermit) on Jan 22, 2001 at 03:12 UTC
    I want to thank I0 for correcting some bugs:
    1. '[' is apparently a reserved character in Perl REs so it needed to be escaped.
    2. The ? in .*? turns off greedy matching. Thus everything after id= will be matched but only up until the first '[' it encounters.