Solved

Replace character with backslash

Posted on 2013-11-04
3
294 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
3 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
Comment Utility
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
Comment Utility
Thanks a lot. I was convinced it was the "\" that caused the problem.
0
 
LVL 14

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now