Currently I'm using:
\v(((^|,)[^,]*){3})(.*)
to match csv lines, the first part ((^|,)[^,]*){3}
is to match 3 items, then the second part .*
matches the rest.
However, if the csv line starts with a empty item, e.g. ,2,3,4,5
, the regex will not match correctly, as ^
seems can be matched multiple times.
How could I avoid this, to make ^
matched only once?
Of course I can use:
\v(^[^,]*)((,[^,]*){2})(.*)
but then the matching items increased and other codes become more complex. I wonder if there is a "local" fix here.