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
  • 38,339
  • 11
  • 92
  • 126
pcwizz
  • 146
  • 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
  • 65,133
  • 10
  • 87
  • 119