需求:使用mongo shell查询 student 集合中 stuNo学号 是1开头,并且是9位数 的学生
db.student.find({stuNo:{$regex:'^1[0-9]{8}', $options:'i'}})
options操作符:
- i(不区分大小写),
- m(当使用^与$符号模糊匹配时,作用于屏蔽中间的换行符) ,
- x(忽略注释,以#开头 /n结尾),
- s(允许所有字符包括换行符参与模糊匹配)
参考:https://blog.csdn.net/Nick_666/article/details/81286239