MongoDB RegEx not working

后端 未结 2 881
北荒
北荒 2021-01-28 05:12

I\'m trying to return documents that whose obsNum field starts with 1.. I have written the following RegEx to filter out those documents however, it returns all the

2条回答
  •  终归单人心
    2021-01-28 05:50

    The regular expression you might try is:

    ^(1\.\d+)
    

    Explanation:

    • ^ Beginning of the string
    • (…) Capturing parentheses: remember the match
    • 1 Literal digit
    • \d decimal digit
    • + At least one

提交回复
热议问题