Flutter/Dart使用正则表达式
匹配-验证手机号 普通 js写法
RegExp exp=RegExp('^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$');
boolmatched=exp.test(mobileTextController.text);
匹配-验证手机号 flutter写法
RegExp exp=RegExp(r'^((13[0-9])|(14[0-9])|(15[0-9])|(16[0-9])|(17[0-9])|(18[0-9])|(19[0-9]))\d{8}$');
boolmatched=exp.hasMatch(mobileTextController.text);
在flutter正则中需要在正则写法前加r