in reply to Re: Parsing and Obtaining Values from output
in thread Parsing and Obtaining Values from output
/[(.*?)]/ won't match anything having to do with square brackets. It is a character set (the [] metacharacters) consisting of the ( ) . * ? characters.
Update: Something like m{ \[ ([^]]*) \] }xms might be useful:
>perl -wMstrict -le "my $s = 'foo [bar baz] quux [%^&*] boff [] biff'; my @bracketed = $s =~ m{ \[ ([^]]*) \] }xmsg; print qq{'$_'} for @bracketed; @bracketed = $s =~ m{ \[ [^]]* \] }xmsg; print qq{'$_'} for @bracketed; " 'bar baz' '%^&*' '' '[bar baz]' '[%^&*]' '[]'
|
|---|