Java USES regular expression as an easy way to add thousands to Numbers

  • 2020-04-01 03:14:19
  • OfStack

The Java support for regular expressions is perfect, with zero-width assertions to add thousands to integers in a single sentence.


"1234567890".replaceAll("(?<=\d)(?=(?:\d{3})+$)", ",");
// => 1,234,567,890


Related articles: