firmament has asked for the wisdom of the Perl Monks concerning the following question:
But even though $1 when printed includes the parenthesis, the substitution statement does not remove them. Am I missing something trivial (probably)? Many thanks.my $s = "bla bla (parenthesis) somestring"; if ($s =~ /.*(\(parenthesis\))\s*somestring/) { print "matched $1\n"; #this prints "(parenthesis)" $s =~ s/$1//; # $s now looks "bla bla () somestring" rather than the desired + "bla bla somestring" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove text within parenthesis
by choroba (Cardinal) on May 07, 2013 at 22:11 UTC | |
by firmament (Novice) on May 08, 2013 at 07:32 UTC | |
|
Re: Remove text within parenthesis
by gurpreetsingh13 (Scribe) on May 08, 2013 at 03:52 UTC | |
|
Re: Remove text within parenthesis
by jnyman (Acolyte) on May 08, 2013 at 12:06 UTC | |
by BillKSmith (Monsignor) on May 08, 2013 at 15:29 UTC | |
|
Re: Remove text within parenthesis
by Anonymous Monk on May 07, 2013 at 22:14 UTC |