in reply to Elegant examples to parse parenthesised strings
I guess another fairly brute force approach..
#!/usr/bin/perl -w use strict; my $line = "05/04/2010 13:09:45 - A - somebody - ( (( my.my id >= 1 )) + ) and ( ( is-relative.to code = 'sister' ) or ( is-relative.to code += 'brother' ) or ( is-mother.to code = 'dog' ) )"; my @terms = $line =~ /\(.*?\)/g; foreach (@terms) { s/.*(\(.*\)).*/$1/; s/^\(\s*//; s/\s*\)$//; print "$_\n"; } __END__ Prints: my.my id >= 1 is-relative.to code = 'sister' is-relative.to code = 'brother' is-mother.to code = 'dog'
In Section
Seekers of Perl Wisdom