ultranerds has asked for the wisdom of the Perl Monks concerning the following question:
Basically, the output I'm after is: Tag: 345fsdf sf Tag: sdf sf fsd fsf Tag: foo bar|whatever Tag Contents: == foo bar === foo bar testmy $current_article = qq| [sommaire foo bar 3] [[345fsdf sf]] [[sdf sf fsd fsf]] [[foo bar\|whatever]] == foo bar === foo bar test [/sommaire] |; while ($current_article =~ m/\[\[(.+?)\]\]/g) { my $tag_name = $1; print "Got $tag_name \n"; print "Checking if we have any contents AFTER it... \n"; print "RUNNING: \Q[[$tag_name]]\E(.*?)\[ \n"; if ($current_article =~ /\Q[[$tag_name]]\E(.*?)\[/) { print "Got contents: $1 and $2 \n"; } print "\n\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't quite get this regex working
by GrandFather (Saint) on Apr 08, 2011 at 11:18 UTC | |
|
Re: Can't quite get this regex working
by bart (Canon) on Apr 08, 2011 at 12:07 UTC | |
|
Re: Can't quite get this regex working
by jethro (Monsignor) on Apr 08, 2011 at 11:18 UTC | |
by GrandFather (Saint) on Apr 08, 2011 at 11:30 UTC | |
by moritz (Cardinal) on Apr 08, 2011 at 11:41 UTC | |
by JavaFan (Canon) on Apr 08, 2011 at 11:50 UTC | |
by ultranerds (Hermit) on Apr 08, 2011 at 11:37 UTC | |
by ultranerds (Hermit) on Apr 08, 2011 at 11:20 UTC |