Kat*_*esa 0 regex mongodb jongo
我有一个有1000个记录的集合有一个字符串列.
我正在使用Jongo API来查询mongodb.
我需要找到匹配的记录,其中列字符串以字母"AB"开头,以斜杠"/"结尾
需要查询查询的帮助以选择相同的.
谢谢.
我将假设您知道如何使用Jongo API中的正则表达式进行查询,并且只是在寻找必要的正则表达式吗?
如果是这样,这个正则表达式将找到任何以'AB'开头的字符串(区分大小写),后跟任意数量的其他字符,然后以正斜杠('/')结束:
^AB.*\/$
^ - matches the start of the string
AB - matches the string 'AB' exactly
.* - matches any character ('.') any number of times ('*')
\/ - matches the literal character '/' (backslash is the escape character)
$ - matches the end of the string
Run Code Online (Sandbox Code Playgroud)
如果您刚开始使用正则表达式,我强烈推荐使用Regex 101网站,这是一个非常棒的沙箱来测试正则表达式,并解释了表达式的每一步,使调试变得更加简单.