Solved

regex help

Posted on 2014-03-16
2
165 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 68

Accepted Solution

by:
Qlemo earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This article will help you understand what HashTables are and how to use them in PowerShell.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

21 Experts available now in Live!

Get 1:1 Help Now