dart flutter
i need regular expression to know if a string variable than coming from user inputs contains more than 1 same input
wanted inputs that i want handle it (- _ .)
the wanted input that i won't be repeated more than once is - or . or _
lets say user wrote Alex.9
.. well it is sound good because he wrote one dot
well i already know how to handle in case there are two dot next to each other like Alex..9
with using contains('..')
, but if those two dots were not next to each other like A.le.x result will be false
what i want by no and ok :=
Alex.9 => ok
A.le.x => no
Alex-9 => ok
A-le-x9 => no
Alex_9 => ok
Al_e_x9 => no
// also if there was two or the whole difference of (- _ .) in the same string. like
A.le-x => no
A.le_x => no
A-l_9 => no
A.l-x_9 => no
sample of what i mean
final TextEditingController nameController = TextEditingController();
Scaffold(
body: nameController.text.contains(RegExp('Is - or _ or . duplicated?'))?
Text('yes duplicated') : Text('not duplicated'),
);
CodePudding user response:
regular expression: [._-](.*[._-])