var num = "1234567.89";
var num1 = num.replace(/(?<=\d)(?=(\d{3})+\b)/g, ",");
// \b 1,234,567.89
var num2 = num.replace(/(?<=\d)(?=(\d{3}))/g, ",");
// \b 1,2,3,4,567.89
\b
\b
var num = "1234567.89";
var num1 = num.replace(/(?<=\d)(?=(\d{3})+\b)/g, ",");
// \b 1,234,567.89
var num2 = num.replace(/(?<=\d)(?=(\d{3}))/g, ",");
// \b 1,2,3,4,567.89
\b
\b
regular expression testing tool
. This kind of question, can you check the official api? You should be ashamed to ask such a question. B and b are both word boundary matchers
.Previous: How to solve the problem of html rendered by markdown-it without style
Next: How to deal with statements in http document format with Xpath directly under Python?