开发者

parsing regex csv with quotes as strings and non quotes as numbers

开发者 https://www.devze.com 2023-03-04 12:53 出处:网络
I\'m trying to figure out a way to parse this CSV 开发者_如何学Gowith the following entry: \"So, can\'t believe someone, made this comma format\", 77777, 3, 2, \"the customer thought that this is \"s

I'm trying to figure out a way to parse this CSV 开发者_如何学Gowith the following entry:

"So, can't believe someone, made this comma format", 77777, 3, 2, "the customer thought that this is "so brilliant!" to do."

The quotes represents strings and non-quotes represents integers. What makes this even more complex is there can be nested quotes and commas inside for the string. Is there a way to parse this and if so what would be the regex?

Thanks in advance!


It is possible to identify all the separator commas. But since you didn't say what programming language you are using so here is the one for Java:

(?:[0-9\"])[ ]*,[ ]*(?:[0-9\"])

It simply find comma that surround by either number or quote. Hope this help.

0

精彩评论

暂无评论...
验证码 换一张
取 消