【发布时间】:2021-12-28 02:29:57
【问题描述】:
飞镖 颤动
我需要正则表达式来知道来自用户输入的字符串变量是否包含超过 1 个相同的输入
我想要处理的想要的输入 (- _ .)
我不会重复多次的想要的输入是 - 或 .或_
假设用户写了Alex.9 .. 听起来不错,因为他写了一个点
好吧,我已经知道如何处理,以防两个点相邻,例如Alex..9
使用contains('..'),但如果这两个点不是像A.le.x那样彼此相邻,结果将是false
我想要的不是和好的:=
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
我的意思示例
final TextEditingController nameController = TextEditingController();
Scaffold(
body: nameController.text.contains(RegExp('Is - or _ or . duplicated?'))?
Text('yes duplicated') : Text('not duplicated'),
);
【问题讨论】:
标签: regex string flutter dart string-length