LoginSignup
3
2

More than 5 years have passed since last update.

\bはバックスペースでなく単語境界なので正規表現でうまく動作しない

Last updated at Posted at 2018-01-30

検索したけど見つからなかったので自分用メモ

※追記 コメントありがとうございます
[\b]を使えばうまくいきまいした

JavaScript
str = str.replace(/[\b]+/g, '');

  • バックスペースを削除
JavaScript
str = str.replace(/\x08+/g, '');
  • バックスペースやタブ、改行などを削除
JavaScript
str = str.replace(/[\x08-\x0D]+/g, '');

ASCII制御文字

3
2
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
3
2