I’m adding a text input formatter as extension, What is the regex for this case:
-
Allow english/arabic characters and numbers.
-
Block all special characters except DOT. DASH- SINGLEQUOTE’
here is my regex:
static final RegExp _allowFewSpecialCharacters = RegExp(r"[a-zA-Z0-9u0600-u06FFp{L}p{Nd}s!.-']");
Method:
static TextInputFormatter filterSpecialCharacters() {
return FilteringTextInputFormatter.deny(_allowFewSpecialCharacters);
}
usage:
TextField(
decoration: const InputDecoration(labelText: 'Allow few characters'),
inputFormatters: [AppTextInputFormatters.filterSpecialCharacters()],
),
My approach is not working, what is wrong and how this task can be accomplished ?