in reply to Regex for outside of brackets

use strict; use warnings; use Test::More; my @rec = ( { have => 'THIS IS OUTSIDE (THIS IS INSIDE)', want => 'THIS IS OUTSIDE ' }, ); plan tests => scalar @rec; for my $this (@rec) { my ($have) = $this->{have} =~ /^([^(]*)/; is ($have, $this->{want}) }

Replies are listed 'Best First'.
Re^2: Regex for outside of brackets
by theravadamonk (Scribe) on Jul 13, 2018 at 17:45 UTC

    Thanks a lot

    here's my easy code

    #!/usr/bin/perl use strict; use warnings; my $string ="THIS IS OUTSIDE (THIS IS INSIDE)"; print "\n"; print "string: $string"; print "\n"; #(my $new_string = $string) =~ s/^([^(]*)/THIS_IS_OUTSIDE_CAPTURED/g; (my $new_string = $string) =~ s/^([^(]*)//g; print "\n"; print "new_string: $new_string"; print "\n\n";