Regular Expression For Formatted Number With Space As Thousand Separator

A Regular Expression for those who use a space as thousands separator.

/(^(((\d)|(\d\d)|(\d\d\d))(\xA0|\x20))*((\d)|(\d\d)|(\d\d\d))([,.]\d*)?$)/

Matches:

  • 123 456
  • 123 456.78
  • 1 234

Non-matches:

  • 123456.78
  • 123,456.78
  • 1234

See Also:

Regex Is Copied!