#!/usr/bin/perl -w use strict; my $bold = "[b]bold text[/b]"; my $red = "[color=Red]Red text text[/color]"; my $red_bold = "[color=Red][b]Red bold text[/b][/color]"; my $empty = "[color=Red][b][/b][/color]"; &check_tags($bold); &check_tags($red); &check_tags($red_bold); &check_tags($empty); sub check_tags { my $tag = shift; print $tag, $/ if $tag =~ /(?:\[[^\]]+\])+.+?(?<!\])(?:\[\/).+/; } __END__ __OUTPUT__ [b]bold text[/b] [color=Red]Red text text[/color] [color=Red][b]Red bold text[/b][/color]
In reply to Re^3: Regex help
by Dietz
in thread Regex help
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |