0

As a user I would like to see space ' ' thousand separator instead of a comma or dot on any website that I encounter in a browser. Is it possible to implement something like that perhaps with a user JS (using Tampermonkey, Greasemonkey etc..)?

e.g. 1,234,567 or 1.234.567 change to 1 234 567

  • 1
    You would have to differentiate between thousands separators and decimal points somehow. – CertainPerformance Jun 09 '18 at 04:56
  • Possible duplicate of [Javascript Thousand Separator / string format](https://stackoverflow.com/questions/3753483/javascript-thousand-separator-string-format) – Alexander Jun 09 '18 at 05:01

1 Answers1

1

You can use RegEx /[,.]/g to replace() those characters with space character. Try the following way:

function formatStr(str){
  str = str.replace(/[,.]/g, ' ');
  return str 
}

console.log(formatStr('1,234,567'));
console.log(formatStr('1.234.567'));
Mamun
  • 66,969
  • 9
  • 47
  • 59