Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Replace the double quote escape sequence as unescape sequence

by PerlRider (Initiate)
on Feb 07, 2013 at 12:15 UTC ( #1017632=perlquestion: print w/ replies, xml ) Need Help??
PerlRider has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I have string which is having double quote. I need a regex to replace all double quotes " with a \" that are inside a single quoted string. Below is the example: $cmd = 'AT +CGDCONT= 1,"IP","","",1,1' I need output as: 'AT +CGDCONT= 1,\"IP\",\"\",\"\",1,1' To make it clear, I want a regular expression only, not a perl program. Thanks in advance..!

Comment on Replace the double quote escape sequence as unescape sequence
Re: Replace the double quote escape sequence as unescape sequence
by Corion (Pope) on Feb 07, 2013 at 12:19 UTC

    If you get a Perl program, can't you extract the regular expression from it?

    What part of perlre (and perlretut) have you read and what problems did you encounter that prevented you from successfully completing your task?

Re: Replace the double quote escape sequence as unescape sequence
by Anonymous Monk on Feb 07, 2013 at 12:23 UTC

      My reaped threats because of the responses I got.
      Why should I unnecesarily scold someone?
      
      

        Why should I unnecesarily scold someone?

        Why should you scold someone?

        No, never

        Ok, here's some news, you

        never

        threaten anyone here, in English or any another language, let alone your disgusting "send your wife" comments. If you don't like it head to www.4chan.org/b, see how well you match up to real trolls. Oh, and read what these pages tell you about formatting your posts, but you've been told that a load of times already.
Re: Replace the double quote escape sequence as unescape sequence
by tobyink (Abbot) on Feb 07, 2013 at 12:29 UTC
    $cmd = 'AT +CGDCONT= 1,"IP","","",1,1'; # A regular expression only... $cmd =~ /(?{s{"}{\\"}g;print"'$_'\n"})/;
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re: Replace the double quote escape sequence as unescape sequence
by Anonymous Monk on Feb 07, 2013 at 12:41 UTC
    search is for everybody  [ddg://double quote site:perlmonks.org] Pattren matching

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-07-10 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (214 votes), past polls