7
I’m having a problem to re-adapt this function in JS.
function mcc(v){
v=v.replace(/\D/g,"");
v=v.replace(/^(\d{4})(\d)/g,"$1 $2");
v=v.replace(/^(\d{4})\s(\d{4})(\d)/g,"$1 $2 $3");
v=v.replace(/^(\d{4})\s(\d{4})\s(\d{4})(\d)/g,"$1 $2 $3 $4");
return v;
}
Basically it adds one('space') to every 4 digits. I would like to add one dot instead of space.
What should I change?
The code for point is
\.
(backslash + stitch). Just replace.– Cleiton Oliveira
I don’t get it, I could add the code he posted the most to your change?
– Marconi
@Cleition, I tried to do this, but it’s not right!
– user50712
Not yet -> 1234.12345678912345 , not so -> 123.5678.9123.1234
– user50712
I only considered replacing space by point, not corrections in the code. This was not requested.
– Cleiton Oliveira