You are failing to escape the parenthesis, so they are carrying their structural meaning rather than being treated as plain old anchor text in the pattern. Simalarly the + is a quantifier; it carries meaning as well. Try this:
s/& \(0\+255\)//;
Here's an example:
my $have = q{clrf __pbssCOMRAM& (0+255),c}; my $want = q{clrf __pbssCOMRAM,c}; $have =~ s/& \(0\+255\)//; print "$have\n$want\n"; print "They ", ($have eq $want ? '' : "don't "), "match\n";
If you want to figure out how to use regular expressions with Perl, perlretut and perlrequick are good starting points.
Another strategy is to tell Perl that what follows should have any "special characters" escaped automatically:
s/\Q& (0+255)//;
The \Q feature is documented in quotemeta.
Dave
In reply to Re: Arguments to substitution question
by davido
in thread Arguments to substitution question
by rich.wilder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |