java - Splitting on "," but not "\," -
this question has answer here:
i'm looking regular expression match , ignore \, in java's regex engine. comes close:
[^\\], however, matches previous character (in addition comma), won't work.
perhaps regular expression approach wrong 1 altogether. intending use string.split() parse simple csv file (can't use external library) escaped commas.
you need negative look-behind assertion here:
string[] arr = str.split("(?<![^\\\\]\\\\),"); note need 4 backslashes there. first escape backslash java string literal. , again escape both backslashes regex.
Comments
Post a Comment