0

I have a $cbDescription variable in a Perl script. When I print out $cbDescription, I get the following:

tIP SOLD -5 /ESH4 @1832.00

I want to remove any + or - or @ signs or commas from the string, so I have the following line:

$cbDescription =~ s/[+-\@,]//g;

I expect that line to change $cbDescription to:

tIP SOLD 5 /ESH4 1832.00

But when I print out $cbDescription after that line, I get:

tIP SOLD  ESH

Why did it also remove all the numbers and the decimal point?

pacoverflow
  • 1,975

1 Answers1

1

- is a range delimiter in between brackets sou you need to escape it:

% echo "tIP SOLD -5 /ESH4 @1832.00" | perl -pi -e 's/[+\-\@,]//g'
tIP SOLD 5 /ESH4 1832.00
Teun Vink
  • 2,465
  • 17
  • 19