请教一个用正则表达做搜索的问题?
发布于 4 年前 作者 jie45 5777 次浏览 来自 问答

有以下4条数据

大神很厉害

大神很帅

高手很厉害

高手很帅

我用这个正则表达式智能搜索出大神或者厉害或者高手这种单词组或单字,我想像搜索引擎那种

通过 大神 +空格 厉害

精准搜索出 大神很厉害 这条。。。请问呢有什么办法或者思路能指教下小弟!不尽感激!

    search(){
      wx.cloud.database().collection('test').orderBy('riqi','desc').where({
        sousuo:wx.cloud.database().RegExp({
          regexp:this.data.inputValue , 
          options:'i'
        
      })
    }).get()
      .then(res=>{
        console.log(res)
        this.setData({
          dataList:res.data
        })
      })
    }
回到顶部