I'm beginner at regular expression. I need your advice on it.
I want to split a string by commas which are outside a couple of single quote with regular expression.
Regex pattern: ,(?=([^']*'[^']*')*[^']*$)
String input: "'2017-10-16 10:44:43.0000000', 'Abc,'', de', '0', None"
Expected output: ["'2017-10-16 10:44:43.0000000'", " 'Abc,'', de'", " '0'", " None"] there is an array with 4 elements.
Currently, I'm using split method with regex and It's working well on JAVA. Now I have to handle it by JavaScript but I have got an unexpected result!
Could you please give me an advice?
Thanks for your help!
.split(',')should work! whatunexpected resultare you getting?'Abc,'in thatinput. That comma is part of the string, it's not a separator.'Abc,'', de'is one element.