?
Solved

Replace character with backslash

Posted on 2013-11-04
3
Medium Priority
?
304 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 2000 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

770 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