May 20, 2021 WeChat Mini Program Development Document
Construct a regular expression that only needs to be used if the normal js regular expression cannot be satisfied
Options support the three flags i, m, s, note that JavaScript native positive objects are constructed with only i, m two flags, so you must use db when using s this flag. T he RegExp constructor constructs a positive object. The meaning of flag can be found in the table below:
flag | Description |
---|---|
Ⅰ | Case is insensitive |
M |
Cross-line matching;
^
$
|
s |
Allows
.
to match all characters, including line breaks
|
// 原生 JavaScript 对象
db.collection('todos').where({
description: /miniprogram/i
})
// 数据库正则对象
db.collection('todos').where({
description: db.RegExp({
regexp: 'miniprogram',
options: 'i',
})
})
// 用 new 构造也是可以的
db.collection('todos').where({
description: new db.RegExp({
regexp: 'miniprogram',
options: 'i',
})
})