亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

pymongo - MongoDB用正則查詢時(shí)如何轉(zhuǎn)義查詢條件中的字符?
伊謝爾倫
伊謝爾倫 2017-04-21 11:16:36
0
1
730
keyword = ''
post = collection.find({ 'key': '/^' + keyword })

如上面的代碼所示,當(dāng)keyword包含一些正則符號(hào),比如$之類(lèi)時(shí),查詢結(jié)果就不準(zhǔn)確了。
不知道m(xù)ongodb有沒(méi)有內(nèi)置轉(zhuǎn)義的方法,還是說(shuō)必須要外部對(duì)keyword進(jìn)行轉(zhuǎn)義?

伊謝爾倫
伊謝爾倫

小伙看你根骨奇佳,潛力無(wú)限,來(lái)學(xué)PHP伐。

reply all(1)
小葫蘆

Mongodb’s regular expression query has two formats
One is {key:{$regex:".*"}}
The other is {key:/.*/}
For the first escape use \
The second use

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template