regex - Capture numbers and strings from comma separatated value file -


i have file contains strings begins , end double quotes. each string can contain comma. numbers not begin or end double quotes. each integer , string separated comma. possible have null value.

i make groups witch each string , number. trying capture each group 1 @ time.

i have created regex, works every case unless there comma in string:

/(?:"?([^"]*)"?,){2}/u 

if remove ungreedy operator, regex works every case except null values.

here example of log file:

196778,"df,fdfsdf","4.4","ds-sdads231-33","mmh",1,,,,,,,023,1,"20150,62519535ty" 

https://regex101.com/r/ko5wm4/3

you can use regex:

(?:(?:"([^"]*)"|([^,]*))(?:,|$)){2} 

regex demo


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -