I have a text edit controller and I would like to check mutliple characters in the same contains ()
_changeUsernameController.text.contains("a" "b") // what I want
_changeUsernameController.text.contains("a") ||
_changeUsernameController.text.contains("b") // what I have to do
I don’t want to write 50 lines so how can I write all in one line like the ‘what I want’ line
Thanks
3
Answers
You can achieve this by
RegExp
, try this:example:
Create a function like this:
Example:
You can use the any method to write less code for the very same effect:
Or if you prefer it even shorter: