Novocaine Novocaine - 2 months ago 21
JSON Question

Wrap integers in quotes from json data

I created this question yesterday

I've since realised there are actually a few other bits of data that cause issues with the solutions I received. Hence, I thought it best to make a new question

Take the following example data;

"87",0000,0767,"078",0785,"0723",23487, "061 904 5284","17\/10\/2016",""

Using the accepted solution form above

The date string ends up having the middle number in between the two
wrapped, the number in quotes with spaces breaks as well as the email address.
The issues can be seen here:

My Solution

The following does seem to work for me, however it seems a bit messy. I have a feeling there's a much more succinct way to achieve the same result;

,(?<!("|\/|\\))(\b\d+\b)(?!("|\/|\\|( \d)))
Replace with


@Federico this screenshot shows that spaces before or after commas breaks the replace;
enter image description here


By reading your both questions, what I understand is that you want to wrap in double quots some numbers that aren't, so for this I can come up with a simple regex like this:


With the replacement string: "$1"

Working demo

enter image description here

Update: after you updated the question, here I put the update for the answer. You can use this regex instead: