Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How to escape single quote(s) without the use of quotemeta

by hippo (Chancellor)
on Apr 05, 2019 at 14:43 UTC ( #1232193=note: print w/replies, xml ) Need Help??


in reply to How to escape single quote(s) without the use of quotemeta

Is this what you are after?

use strict; use warnings; use Test::More tests => 1; my $have = "This sting it's bothering to escape ' single characters"; my $want = "This sting it\\'s bothering to escape \\' single character +s"; $have =~ s/'/\\'/g; is $have, $want;

Replies are listed 'Best First'.
Re^2: How to escape single quote(s) without the use of quotemeta
by thanos1983 (Parson) on Apr 05, 2019 at 14:49 UTC

    Hello hippo,

    Thanks it works. I thought also about escaping the back slash character and I have tried it but it did not worked for me. I guess s and g is what I was looking for.

    Thanks again for your time and effort.

    BR / Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232193]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2021-06-16 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (75 votes). Check out past polls.

    Notices?