Need some help(
I have a string:
:01:Test1:1111:02:Test2:2222:03:Test3:3333
I need to separate it with reg expression like this:
:01:Test1:1111
:02:Test2:2222
:03:Test3:3333
I have an expression and it works great, if all parameters has values:
:.+?:.+?:[^:]+
But if I have a parameter with null value, like:
:01:Test1:1111:02:Test2::03:Test3:3333
I’ll get this result:
:01:Test1:1111
:02:Test2::03
But I need:
:01:Test1:1111
:02:Test2:
:03:Test3:3333
How should I change my regexp to fix this situation and get correct result for each situation?
>Solution :
The issue here is that + is one to unlimited times whereas you’re looking for zero to unlimited times, and greedy.
Try:
:.+?:.+?:[^:]*+