Pattern Match Question..

Discussion in 'Perl Misc' started by Rodney, Sep 13, 2003.

  1. Rodney

    Rodney Guest

    I want to replace all instances of the combination of \" with \"

    Using the Regex code below, I end up replacing ALL " with &guot; and all
    \" with \&guot;
    How can I make it ONLY replace the combination of \" ?

    $TextBlockToConvert =~ s/\"/\quot;/g;

    NOTE:
    The combination of \" may or may not have other characters butting up
    against either or both sides of it.


    Thanks,
    --
    ....
    `·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
     
    Rodney, Sep 13, 2003
    #1
    1. Advertising

  2. Rodney wrote:
    >
    > I want to replace all instances of the combination of \" with \"
    >
    > Using the Regex code below, I end up replacing ALL " with &guot; and all
    > \" with \&guot;
    > How can I make it ONLY replace the combination of \" ?
    >
    > $TextBlockToConvert =~ s/\"/\quot;/g;


    The backslash character is special in double quoted strings so you have
    to escape it if you want a literal backslash character.

    $TextBlockToConvert =~ s/\\"/"/g;



    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Sep 13, 2003
    #2
    1. Advertising

  3. Rodney

    Rodney Guest

    That did it perlfectly!

    Thanks John.
    --
    ....
    `·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney
     
    Rodney, Sep 14, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hiwa
    Replies:
    0
    Views:
    640
  2. BCC

    Pattern match question

    BCC, Aug 23, 2004, in forum: C++
    Replies:
    6
    Views:
    424
    Alex Vinokur
    Aug 24, 2004
  3. Chris

    Pattern Match Question

    Chris, Jun 4, 2008, in forum: Java
    Replies:
    5
    Views:
    391
    Roedy Green
    Jun 4, 2008
  4. Replies:
    5
    Views:
    144
    Tad McClellan
    Jan 15, 2005
  5. Allan M. Due
    Replies:
    5
    Views:
    103
    A. Sinan Unur
    Nov 13, 2005
Loading...

Share This Page