Reputation: 175
I have string like this:
$string= "only this I need"
.
I am new in perl, and I tried to translate a PL/SQL code in perl.
My goal is to replace "
with a blank space, finally it should look like this:
$string = only this I need
In PL/SQL I use this, and is working very well:
REGEXP_REPLACE(string,'"','');
In perl I tried this, but is not working: $string=~s/"/'';
receiving an error.
Please, help me, tell me what I need to read to do my job properly?
Upvotes: 0
Views: 133
Reputation: 4709
This is a way to remove quotes from string:
my $string= '"only this I need"';
$string =~ m/"([^"]*)"/;
print "$1\n";
In case if you know the first and last character is quotes, you can do this without using regex
, just use substr
:
my $string= '"only this I need"';
$string = substr $string, 1, -1;
print "$string\n";
Upvotes: 0
Reputation: 3535
Try this it should work:
use strict;
use warnings;
my $string= '"only this I need"';
print "$string \n"; #prints "only this I need"
$string =~ s/"/ /g;
print "$string \n"; #prints only this I need
Upvotes: 2