Windows Vista Forums

escape character question - hopefully an easy question
  1. #1


    Cookiecutter Guest

    escape character question - hopefully an easy question

    When a string with an escape character is enclosed in double quotes ( ie.
    "k`[][][]") , the escape character is removed. With the given example, the
    string becomes k[][][]. However, if it is enclosed in single quotes, it
    retains the little 'tick'.



    I'm working with ADO recordsets and fields of data from access databases
    which are returned in the double-quote string format. Is there anyway I can
    retain the 'tick' in this situation? I've tried "k`[][][]"
    -replace('`','``'), but this does not seem to work. Is there a simple
    solution?

      My System SpecsSystem Spec

  2. #2


    RichS [MVP] Guest

    RE: escape character question - hopefully an easy question

    I just tried this and it worked

    PS> "k`[][][]"
    k[][][]
    PS> "k``[][][]"
    k`[][][]

    I don't think the replace will work as the single ` is lost as you build the
    string
    --
    Richard Siddaway
    All scripts are supplied "as is" and with no warranty
    PowerShell MVP
    Blog: http://richardsiddaway.spaces.live.com/
    PowerShell User Group: http://www.get-psuguk.org.uk


    "Cookiecutter" wrote:

    > When a string with an escape character is enclosed in double quotes ( ie.
    > "k`[][][]") , the escape character is removed. With the given example, the
    > string becomes k[][][]. However, if it is enclosed in single quotes, it
    > retains the little 'tick'.
    >
    > I'm working with ADO recordsets and fields of data from access databases
    > which are returned in the double-quote string format. Is there anyway I can
    > retain the 'tick' in this situation? I've tried "k`[][][]"
    > -replace('`','``'), but this does not seem to work. Is there a simple
    > solution?

      My System SpecsSystem Spec

  3. #3


    RickB Guest

    Re: escape character question - hopefully an easy question

    On Jan 28, 7:36*pm, Cookiecutter
    <Cookiecut...@xxxxxx> wrote:

    > When a string with an escape character is enclosed in double quotes ( ie.
    > "k`[][][]") , the escape character is removed. *With the given example,the
    > string becomes *k[][][]. *However, if it is enclosed in single quotes, it
    > retains the little 'tick'. *
    >
    > I'm working with ADO recordsets and fields of data from access databases
    > which are returned in the double-quote string format. *Is there anyway I can
    > retain the 'tick' in this situation? *I've tried "k`[][][]"
    > -replace('`','``'), but this does not seem to work. *Is there a simple
    > solution?
    The reason your replace doesn't work is because the ` is already gone.
    IOW it was never really in the string to begin with.
    But if you have a string that contains the character then nothing
    should remove it without you taking some explicit action.

      My System SpecsSystem Spec

escape character question - hopefully an easy question problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: exchange shell escape character Bob Butler PowerShell 7 12 Oct 2007
Escape character question lawndart PowerShell 2 07 Aug 2007
How can I escape a slash character in item name? KH.Lee PowerShell 5 08 Jun 2007
howto? escape the comment character public news groups PowerShell 3 02 Nov 2006
Bug in escape character / variable expansion? =?Utf-8?B?Um9tYW4gS3V6bWlu?= PowerShell 4 24 Jul 2006