Windows Vista Forums

How to use quantifier * with -replace ' ', ' '

  1. #1


    Abhishek Seth Guest

    How to use quantifier * with -replace ' ', ' '

    Consider the following arbitrary example:

    "Camel Cow Travel Show" -replace 'el (C|Sh)', 'El $1'

    I would like to repeat $1 say 10 number of times. So I attempted
    "Camel Cow Travel Show" -replace 'el (C|Sh)' 'El $1 * 10'



    This fails. I suppose because of the quoting. But I am unable to figure
    out how to do this. Please help

    Thanks
    --
    Abhishek


      My System SpecsSystem Spec

  2. #2


    Shay Levy [MVP] Guest

    Re: How to use quantifier * with -replace ' ', ' '

    Hi Abhishek,


    Like that?

    "Camel Cow Travel Show" -replace 'el (C|Sh)', "El $('$1'*10)"



    ---
    Shay Levy
    Windows PowerShell MVP
    http://blogs.microsoft.co.il/blogs/ScriptFanatic
    PowerShell Toolbar: http://tinyurl.com/PSToolbar



    AS> Consider the following arbitrary example:
    AS>
    AS> "Camel Cow Travel Show" -replace 'el (C|Sh)', 'El $1'
    AS>
    AS> I would like to repeat $1 say 10 number of times. So I attempted
    AS> "Camel Cow Travel Show" -replace 'el (C|Sh)' 'El $1 * 10'
    AS>
    AS> This fails. I suppose because of the quoting. But I am unable to
    AS> figure out how to do this. Please help
    AS>
    AS> Thanks
    AS>



      My System SpecsSystem Spec

  3. #3


    Abhishek Seth Guest

    Re: How to use quantifier * with -replace ' ', ' '

    Yes, indeed so..

    Thanks Shay

    "Shay Levy [MVP]" <no@xxxxxx> wrote in message
    news:6a18a3577f8758cba1d2610787c6@xxxxxx

    > Hi Abhishek,
    >
    >
    > Like that?
    >
    > "Camel Cow Travel Show" -replace 'el (C|Sh)', "El $('$1'*10)"
    >
    >
    >
    > ---
    > Shay Levy
    > Windows PowerShell MVP
    > http://blogs.microsoft.co.il/blogs/ScriptFanatic
    > PowerShell Toolbar: http://tinyurl.com/PSToolbar
    >
    >
    >
    > AS> Consider the following arbitrary example:
    > AS> AS> "Camel Cow Travel Show" -replace 'el (C|Sh)', 'El $1'
    > AS> AS> I would like to repeat $1 say 10 number of times. So I
    > attempted
    > AS> "Camel Cow Travel Show" -replace 'el (C|Sh)' 'El $1 * 10'
    > AS> AS> This fails. I suppose because of the quoting. But I am unable
    > to
    > AS> figure out how to do this. Please help
    > AS> AS> Thanks
    > AS>
    >



      My System SpecsSystem Spec

How to use quantifier * with -replace ' ', ' '

Similar Threads
Thread Thread Starter Forum Replies Last Post
the PowerShell ?? regular expression quantifier Larry__Weiss PowerShell 0 03 Apr 2010
VBScript String Replace - Remove / Replace Characters in String dsoutter VB Script 17 05 Mar 2010
Should I Replace... Rance Browsers & Mail 3 03 Nov 2009
replace stratos PowerShell 3 21 Oct 2007
Replace IE7 with IE6? Jim Vista General 7 10 May 2007