c# - regex extract match for every fourth comma in the string -


i trying create regex output below string, in sets of 4 comma separated values. have tried selects each comma separated value. don't know how desired output.

the regex tried:

".*?"(?=,|$) 

data:

"t","success","2","2","t","success","6458960","1","f,"you not have sufficient credit.","6458962","1" 

desired out:

"t","success","2","2"   "t","success","6458960","1"   "f,"you not have sufficient credit.","6458962","1" 

update: "the f in double quote too, typo, sorry!"

"t","success","2","2","t","success","6458960","1","f","you not have sufficient credit.","6458962","1"

you use following regex, if f in enclosed quotes:

((?:".+",){3}(?:".+")) 

this results in:

match 1 1. [0-21] "t","success","2","2"

match 2 1. [22-49] "t","success","6458960","1"

match 3 1. [50-104] "f","you not have sufficient credit.","6458962","1"

regex demo

if data in inconsistent form, have parse manually or modify regex or condition.


Comments