I'm splitting a string on pipes (|) and the regex [^|]*
is working fine when there are missing fields, but it's matching null characters after words:
GARBAGE|||GA|30604
yields matches
GARBAGE, null, null, null, GA, null, 30604, null
I've also tried [^|]+
which yields matches
GARBAGE, GA, 30604
EDIT: What I want is GARBAGE, null, null, GA, 30604
. And ||||
would yield matches null, null, null, null, null
.
I'm referencing matches by index, so how can I fix the regex so it matches field by field, including nulls if there is no other data in the field?