Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

regex help

Posted on 2014-03-16
2
Medium Priority
?
175 Views
Last Modified: 2014-03-16
I'm looking for syntax to do the following

original string
01 A Text String

desired replacement
01 - A Text String

I just need to insert a dash between the numeric and the alpha as shown.
There is the one occurrence of this pattern only in the string.

Thanks
0
Comment
Question by:dgrafx
2 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 total points
ID: 39932530
"01 A Text String" -replace '(\d+)\s(.+)', '$1 - $2'

Open in new window

will search for arbitrary number of digits, followed by space, followed by arbitrary characters.
0
 
LVL 25

Author Closing Comment

by:dgrafx
ID: 39932534
perfect - thanks ...
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  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 following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Loops Section Overview
Screencast - Getting to Know the Pipeline

782 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