removeSpecialCharacters method

String removeSpecialCharacters()

Removes special characters from string, leaving only alphanumeric characters and spaces

Example:

"Hello, World!".removeSpecialCharacters(); // Returns "Hello World"
"user@example.com".removeSpecialCharacters(); // Returns "userexamplecom"

Implementation

String removeSpecialCharacters() => replaceAll(RegExp(r'[^\w\s]+'), '');