0

i've to find the sequence of chars ,. inside a json file for example: ":0,.0}},{", so what is the best fitted regex string for it?

i tried /(,.){1,}/g but it doesn't work well.

AppleInside
  • 73
  • 10

2 Answers2

0

you need to escape the .:

/,\./g
melpomene
  • 84,125
  • 8
  • 85
  • 148
Paul
  • 106
  • 1
  • 8
0

It's because . is a special character.

const r = /(?:,\.)+/g
console.log('abc,.,.,.def'.match(r)) //[",.,.,."]
csander
  • 1,385
  • 10
  • 11