Who will explain the regularity of this thousand-point symbol for me?

regular source:
https://github.com/anran758/F.

/**
 * 
 *
 * @param {Number} num - 
 * @returns 
 */
function numberWithCommas(num) {
  // :  \B(),  (\d{3})+(?!\d)
  // (\d{3})+ 
  // (?!\d) , .
  // , (?=), \B
  //  ..
  return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

// "12,345"
"12345".replace(/\B(?=(\d{3})+(?!\d))/g, ",");

// "123,456e"
"123456e".replace(/\B(?=(\d{3})+(?!\d))/g, ",");

several forms of regularization used here are as follows (extracted from encyclopedia):

\ B
matches non-word boundaries. "er\ B" matches "er" in "verb", but not "er" in "never".

\ d
matches a numeric character. Equivalent to [0-9]. Grep needs to add-P Perl regular support
(? = pattern)
non-acquisition match, positive pre-check, and match the search string at the beginning of any string that matches pattern. The match does not need to be obtained for later use. For example, "Windows (? = 95 | 98 | NT | 2000)" matches "Windows" in "Windows2000", but not "Windows" in "Windows3.1". Pre-checking does not consume characters, that is, after a match occurs, the next matching search begins immediately after the last match, rather than after containing the pre-checked characters.

(?! pattern)
does not get a match, forward negative precheck, matches the lookup string at the beginning of any string that does not match the pattern, and the match does not need to be obtained for later use. For example, "Windows (?! 95 | 98 | NT | 2000)" matches "Windows" in "Windows3.1", but not "Windows" in "Windows2000".

{n}
n is a non-negative integer. Match the determined n times. For example, "o {2}" does not match "o" in "Bob", but can match two o in "food".

+
matches the previous subexpression one or more times (greater than or equal to once). For example, "zo+" can match "zo" and "zoo", but not "z". + is equivalent to {1,}.

(pattern)
matches pattern and gets the match. The obtained match can be obtained from the resulting Matches collection, which uses the SubMatches collection in VBScript and $0 in JScript. $9 attribute. To match parenthesis characters, use "\ (" or "\)".

from my understanding, it is necessary to match\ B, but it must be followed by three numbers and the end cannot be a number. In that case, it can only be matched to the position before 4 in the string 123456e.
12345 does not match, because it does not match my understanding that the end cannot be a number and cannot be matched, but the result matches

.

regularization is a relatively new block for me, so ask the boss for advice

Mar.15,2021

and this regular has a bug
console.log (numberWithCommas (12345678912.1234)
12345678912.1234
after the decimal can't be handled correctly, I don't know which god can help to correct it

.

20180606 Update:
I have nothing to do these days to follow the regularization, and I have a whole answer:

clipboard.png

/ (B (? = (d {3}) + (?! d) D)) | (B (? < = D (d {3}) +)) / g

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b88c-2afe4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b88c-2afe4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?