```
    Math.round(num1/num2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")

```

I have this and if I put 

```
 var num1 = 123456789;
 var num2 = 10000; 

```

I get 12,346 but I do not understand how it works using replace method. Doesn't replace() method replace something, which means a character has to be deleted? But how come this function can insert comma between characters? I understand the regex one by one but do not understand how it works in total. Thanks!