Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振省道替换所有特殊字符不工作_Flutter_Dart - Fatal编程技术网

Flutter 颤振省道替换所有特殊字符不工作

Flutter 颤振省道替换所有特殊字符不工作,flutter,dart,Flutter,Dart,我不能让它工作它不替换所有的特殊字符和空白 String sentence = "!@#$%ˆ&*()<>?:"{} Hello "; String newSentence = sentence.replaceAll("\\W+","").toLowerCase(); print(newSentence); String-句子=“!@$%; 字符串newSentence=句子.replaceAll(“\\W+”,“”)。toLowerCase(); 印刷品(新闻事件); 使

我不能让它工作它不替换所有的特殊字符和空白

String sentence = "!@#$%ˆ&*()<>?:"{} Hello ";
String newSentence = sentence.replaceAll("\\W+","").toLowerCase();
print(newSentence);
String-句子=“!@$%;
字符串newSentence=句子.replaceAll(“\\W+”,“”)。toLowerCase();
印刷品(新闻事件);
使用

输出:

恢复

有关更多参考信息,请尝试以下方法:

  String sentence = "!@#\$%ˆ&*()<>?:\"{} Hello ";
  String newSentence = sentence.replaceAll(RegExp(r'[^a-zA-Z0-9 ]'),"").toLowerCase();
  print(newSentence);
字符串句子=“!@\\$”ˆ&*()?:\“{}你好”;
String newSentence=句子.replaceAll(RegExp(r'[^a-zA-Z0-9]','').toLowerCase();
印刷品(新闻事件);

@phongyewtong:你的答案满意吗?
  String sentence = "!@#\$%ˆ&*()<>?:\"{} Hello ";
  String newSentence = sentence.replaceAll(RegExp(r'[^a-zA-Z0-9 ]'),"").toLowerCase();
  print(newSentence);