Solved

Replace character with backslash

Posted on 2013-11-04
3
303 Views
Last Modified: 2013-11-04
I have run in to at bit of a problem.
I have some Groupnames in the format AAA.BBB.CCC and I want to replace all the dots with backslashes.

I have tried with this:
$a = "AAA.BBB.CCC"
$a -replace ".","\"

Open in new window

But it just returns:
\\\\\\\\\\\\

Open in new window

How do I force it to return
AAA\BBB\CCC

Open in new window

0
Comment
Question by:Kasper Katzmann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39621227
Hi,
the period means any character hence you have to "escape" it like
$a = "AAA.BBB.CCC"
$a -replace "\.","\"

Open in new window


HTH
Rainer
0
 

Author Closing Comment

by:Kasper Katzmann
ID: 39621233
Thanks a lot. I was convinced it was the "\" that caused the problem.
0
 
LVL 14

Expert Comment

by:Ram Balachandran
ID: 39621247
$a.Split(".") | ForEach {  Write-Host "$_/" -nonewline}
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will help you understand what HashTables are and how to use them in PowerShell.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question