Vyacheslav Karamov wrote: > Hi All! > > I need to capture something in braces using regular expressions. > But I don't need to capture wrong data: > > [Some text] - correct > (Some text) - also correct > [Some text) - wrong > (Some text] - also wrong
HTH, Rob use strict; use warnings; while (<DATA>) { while ( / ( \[[^])]+\] | \([^])]+\) ) /xg ) { print $1, "\n"; } } __DATA__ [correct] - correct (also correct) - also correct [wrong) - wrong (also wrong] - also wrong -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/