I've been attempting to learn enough RegEx today to split the following string into the format below:
Original string: foo u:james h c:user p:product
Desired output: ["foo", "u:", "james h", "c:", "user", "p:", "product"]
Actual output: ["foo ", "u", "james h ", "c", "user ", "p", "product"]
The actual output is just missing the colon. It also has trailing spaces, but I can fix that with c# if I can get the full delimiter.
It feels like I'm very close, but I'll confess that the RegEx above required most of my evening. What am I missing?
Here's my RegEx so far:
([a-z]):+
If it's in javascript, you can use the
split
method, and capture the split pattern that you'd like to keep: