in reply to Regex help
.+(?<=\])(.+?)(?=\[\/).+
#!/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 $regex = qr/.+(?<=\])(.+?)(?=\[\/).+/; $bold =~ s/$regex/$1/; $red =~ s/$regex/$1/; $red_bold =~ s/$regex/$1/; print "\$bold: $bold\n"; print "\$red: $red\n"; print "\$red_bold: $red_bold\n"; __END__ __OUTPUT__ $bold: bold text $red: Red text text $red_bold: Red bold text
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex help
by tachyon (Chancellor) on Jul 31, 2004 at 13:19 UTC | |
by ysth (Canon) on Aug 01, 2004 at 05:54 UTC | |
by tachyon (Chancellor) on Aug 01, 2004 at 08:31 UTC | |
|
Re^2: Regex help
by kiat (Vicar) on Jul 31, 2004 at 12:39 UTC | |
by Dietz (Curate) on Jul 31, 2004 at 14:35 UTC |