I have a string that resembles this:
let string = "'arnold', 28, 'software developer', '{"lat":0.31628,"lng":"32.58219"}'"
I would like to split the string by commas and end up with something like this:
['arnold', 28, 'software developer', '{"lat":0.31628,"lng":"32.58219"}']
Reason is, I am working on a legacy system and I want to be able to receive string like that and prepare them for inserts. Is this possible with JavaScript/NodeJS? I have tried using string.split(',')
but I get an undesirable result, i.e it splits the string in the braces. I will appreciate any help in figuring it out.
,(?![^{]*})\s*
- JvdV