5

I have developed some regex in regexr where it works as expected, but when I use it in Go it seems to be mismatching strings.

(\+|-)?(((\d{1,3}[, ])(\d{3}[ ,])*\d{3})|\d+)( ?[\.,] ?(\d{3}[, ])*\d+)?

For example in regexr the following input does not match:

1.12,4.64

But in Go it does match.

John Weldon
  • 39,849
  • 11
  • 94
  • 127
pcwizz
  • 142
  • 7

1 Answers1

5
^(\+|-)?(((\d{1,3}[, ])(\d{3}[ ,])*\d{3})|\d+)( ?[\.,] ?(\d{3}[, ])*\d+)?$

Try with anchors.^$ will disable partial matching.See demo.

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

vks
  • 67,027
  • 10
  • 91
  • 124