I have a string such as:
EB*C*IND*30***23*50.00*****U
And I need to create groups for anything between the *'s.
for example this should be:
Group 1: C
Group 2: IND
Group 3: 30
Group 4: <empty>
Group 5: <empty>
Group 6: 23
Group 7: 50.00
Group 8: <empty>
Group 9: <empty>
Group 10: <empty>
Group 11: <empty>
I can get the Group 0 = EB and the Group 12 = U just fine. but i cant for the life of me figure out how to get those empty groups between the *'s.
I need something that looks at every "" and says "capture everything to right until you get to the next "", and if the next character is "*" then the group is "empty".
The use case is that this raw data is parsed with everything between asterisks as groups in other software, so im trying to figure out how to do it on my own for an automation.
(?!\*)([^*]*)(?<!\*)
yields EB, C, 30, 23, 50.00, U .. but it doesnt create groups for the empty groups because the "." is looking for a real character.
how do i get 3 *'s in a row to spit out two empty groups?
Thanks.
Here is one solution to your problem.
(?<=\*)[^\*]*(?=\*)
(?<=\*)
looks for a *
on the left (?=\*)
*
on the right[^\*]*
looks for anything in between that's not a *
Input: EB*C*IND*30***23*50.00*****U
Output:
Match 1: C
Match 2: IND
Match 3: 30
Match 4:
Match 5:
Match 6: 23
Match 7: 50.00
Match 8:
Match 9:
Match 10:
Match 11:
Test Link: https://regex101.com/r/OQLSCY/1