Dart replaceAllで文字列から空白を削除する

環境
OS windows11 Pro 64bit
Dart 2.18.4

構文
文字列.replaceAll('空白’,")
文字列から空白を全て除去するには、replaceAll関数を使用します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
void main() {
String str = ' s t d u ';
print(str.replaceAll(' ',''));
}
void main() { String str = ' s t d u '; print(str.replaceAll(' ','')); }
void main() {
    
  String str = '  s t  d u  ';

  print(str.replaceAll(' ',''));
}

実行結果
stdu

Dart

Posted by arkgame