如何从Flutter / Dart中的字符串中删除不可打印的字符。
var c ="Maintain central project files (hard copy and electronic) for administration.â¢Perform a wide variety of administrative duties"
感谢您的帮助
答案 0 :(得分:0)
如果您只想保留基本的ascii字符,则可以尝试如下操作:
var c =
"Maintain central project files (hard copy and electronic) for administration.â¢Perform a wide variety of administrative duties";
var clean = c.replaceAll(RegExp(r'[^A-Za-z0-9().,;?]'), ' ');
print(clean);
您会得到:
Maintain central project files (hard copy and electronic) for administration. Perform a wide variety of administrative duties
调整正则表达式以包含更多或更少的字符,具体取决于您希望清除的次数(例如,您可以删除所有标点符号等)