0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[javascript]Replaceについて

Posted at

javascriptを勉強始まります。
下のcodeを良く分かりません。

var text = 'abc def ghi jkl';
text.replace(/(.)\s/g,function(m0, m1){
return ',' + m1
});
//結果:'ab,cde,fgh,ijkl'

2つ質問があります。
1.replace(/s/g,x)--"s"検索して"x"に置換しますが、/(.)\s/g は何ですか?
2.function(m0, m1){
return ',' + m1}は何ですか?(m0: elenment? , m1:index?)
よろしくお願いします。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?