Let me refer to them in reverse order:
What am I doing wrong?
You want to use +, not *. *means zero or more matches, which makes no sense here. +means one or more matches. So:
"aaa\nbbb\nccc".replace(/.+/g, ".")
// ".\n.\n."
, ^ $ ( ), m ( , ). ^ $, . (, ).
javascript ?
, - .
, *, . , , ; , . : .
:
|
"aaa\nbbb\nccc".replace(/.*/g, function(m) {
console.log("m = '" + m + "'");
});
:
m = 'aaa'
m = ''
m = 'bbb'
m = ''
m = 'ccc'
m = ''