Thread: Replace
View Single Post
Old 10-13-2007   #6 (permalink)
Steven Hystad


 
 

Re: Replace

The replace operator supports regex.
To just replace the first space use a regex that only selects the first
space. i.e. '^ '
e.g. $a -replace '^ ',';' | output

<tb@xxxxxx> wrote in message
news:1192269312.197948.307570@xxxxxx
Hej Powershell team.

In gui-help replace it can be defined as - a specified number of
times.
But how should i do, if i only will change the first space and not the
other space
in the following example ???

${C:\powerstart.txt} -replace ' ',';' > C:\powerstart1.txt

I need a real reference manual !!
--------------------------------------------------------------------

Replace

Definition: Returns a string in which a specified substring has been
replaced
with another substring a specified number of times.

$a = "bxnxnx"
$a = $a -replace("x","a")

Regards
Torben Brønsholm
Denmark

My System SpecsSystem Spec