问题描述
我正在尝试搜索这种模式 ab1234。我试过 'foo','bar'
col like 'ab[0-9][0-9][0-9][0-9]'
col like '(ab)[0-9]{4}'
这些都不起作用。我查看了这个网站 https://www.w3schools.com/sql/sql_wildcards.asp,但它不是很有帮助。任何建议表示赞赏:)
解决方法
使用 rlike 进行正则表达式检查:
FutureBuilder<Object>(
future: FirebaseFirestore.instance
.collection('users')
.doc(userId)
.get(),builder: (context,snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Text("Loading...");
}
return Text(
snapshot.data['username'],style: TextStyle(
fontWeight: FontWeight.bold,),);
}
),
或更严格的模式:
col rlike 'ab\\d{4}' --containing ab and 4 digits in any place of the string
,
select * from table where col rlike 'ab[0-9]{4}'