Solved

regex help

Posted on 2014-03-16
2
164 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
Comment Utility
"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 24

Author Closing Comment

by:dgrafx
Comment Utility
perfect - thanks ...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how a content item can be identified directly or through translation of a navigation type. It then shows how this information can be used to create a menu for further navigation.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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…

771 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