Regex to find quotes closest to specific characters

I am trying to match quotes for surrounding timestamps with E9 at the end:

"(?=-?\d*\.?\d+E[+-]?\d+) https://regex101.com/r/bG1tQ9/2

I have the first half of the regular expression, where it matches the quote before E9, but I can not get another quote.

The language is javascript and it will be used for string.replace on compressed json.

+4
source share
2 answers
"(-?\d*\.?\d+E[+-]?\d+)"

You can use this and replace it with. $1Watch the demo.

https://regex101.com/r/bG1tQ9/4

+2
source

Do I think that you want to remove double quotes from the timestamp? If so, then this does the job:

var s = '"23452345235E9", "0342953475409E9", 324598732450843, "fooo", "2034598324509E9", 12342340985, "baaar", 234098549034E9, 453409340923';

var re = new RegExp(/"(\d+E9)"/g);

s = s.replace(re, '$1');

see demo here

+1
source

All Articles