Reputation: 5319
I cant get this to work it doesnt replace all the special character and white spaces?
String sentence = "!@#$%ˆ&*()<>?:"{} Hello ";
String newSentence = sentence.replaceAll("\\W+","").toLowerCase();
print(newSentence);
Upvotes: 1
Views: 1762
Reputation: 953
You should try this:
String sentence = "!@#\$%ˆ&*()<>?:\"{} Hello ";
String newSentence = sentence.replaceAll(RegExp(r'[^a-zA-Z0-9 ]'),"").toLowerCase();
print(newSentence);
Upvotes: 1
Reputation: 34280
Use
String sentense = '!@resu##me'.replaceAll(new RegExp('\\W+'), '');
print(sentense);
Output:
resume
For more reference https://api.dart.dev/stable/2.8.3/dart-core/String/replaceAll.html
Upvotes: 3