in reply to Re: Regex to match between [ref] and [/ref]
in thread Regex to match between [ref] and [/ref]
#!/usr/bin/perl print qq|Content-Type: text/html \n\n|; use Parse::BBCode; # \[\[([^]]+)\|([^]]+)\]\] my $test = qq|==Getting There== testing [ref]bla bla bla [[http://www.google.com]] <b> test </b> and [ +[http://www.google.com\|testing]] [/ref] hhh testing [ref]bla bla bla an[/ref] hhh |; my $p = Parse::BBCode->new({ tags => { # load the default tags Parse::BBCode::HTML->defaults, # add/override tags url => 'url:<a href="%{link}A">%{parse}s</a>', i => '<i>%{parse}s</i>', b => '<b>%{parse}s</b>', noparse => '<pre>%{html}s</pre>', code => sub { my ($parser, $attr, $content, $attribute_fallback) + = @_; if ($attr eq 'perl') { # use some syntax highlighter $content = highlight_perl($content); } else { $content = Parse::BBCode::escape_html($$conten +t); } "<tt>$content</tt>" }, test => 'this is klingon: %{klingon}s', }, escapes => { klingon => sub { my ($parser, $tag, $text) = @_; return translate_into_klingon($text); }, }, } ); my $code = $test; my $parsed = $p->render($code); use Data::Dumper; print Dumper($parsed);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex to match between [ref] and [/ref]
by tinita (Parson) on Jul 17, 2009 at 11:05 UTC |