troubleshooting Question

RegEx, Conditional expression

Avatar of numbers1to9
numbers1to9 asked on
PHPRegular Expressions
7 Comments1 Solution527 ViewsLast Modified:
I have a string that could look like...

([a-z0-9])(:[0-9]*) // i.e. "abc:9145" | "001:447" | "as23a:1" | asv | 124 | etc.

Now, I need to get the first group, without harming the second one (if it exist).

I have tried this (among other things)
/([a-z0-9])([^:0-9])/ $1- $2 // The expected result should be "a-b-c:9145" | "0-0-1:447" | "a-s-2-3-a:1 | a-s-v | 1-2-4"

With little progress.  

I guess what I want to the expression to do is: if 0-9 doesn't start with : (and end with 0-9) select them, and cut them open with '-'.

Is anyone seeing what I am doing wrong? Any suggestions...?
ASKER CERTIFIED SOLUTION
b0lsc0tt
IT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros