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 3 years have passed since last update.

JavaScriptで指定した文字全てを置換する方法

Last updated at Posted at 2020-06-03

個人用にメモ
置換メソッドreplaceについて記述してみる

使い方はこんな感じらしい

[配列名].replace(/`変換対象の文字`/,` 変換後の文字`)

配列に入ってる,だけ取り除いてみる。

//配列生成
const str = "apple,banana,orange";
// 「,」を全て取り除く
const replaced = str.replace(/,/g, ' ')

//出力結果
console.log(replaced) 
apple banana orange

オンライン実行環境
https://paiza.io/projects/WIGdDzgEKj0Ctwf470BSBw

0
0
0

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?