• 请不要在回答技术问题时复制粘贴 AI 生成的内容
SlipStupig
V2EX  ›  程序员

问几个白痴问题

  •  
  •   SlipStupig · Apr 4, 2016 · 2543 views
    This topic created in 3719 days ago, the information mentioned may be changed or developed.
    mongodb 如何筛选制定条件的的数据并且删除掉,比如: email 列中长度小于 6 的,且不带 @符号的,该怎么写呢?
    4 replies    2016-04-05 17:17:55 +08:00
    imxieke
        1
    imxieke  
       Apr 5, 2016
    正则表达式应该可以
    SlipStupig
        2
    SlipStupig  
    OP
       Apr 5, 2016
    @imxieke 具体怎么写呢?
    imxieke
        3
    imxieke  
       Apr 5, 2016
    @SlipStupig 抱歉 没有使用过 Mongodb 不是很清楚
    bwangel
        4
    bwangel  
       Apr 5, 2016   ❤️ 1
    ```
    > db.user.find()
    { "_id" : ObjectId("56d7ced2a2aed7154cef7b03"), "email" : "[email protected]", "first_name" : "Ross", "last_name" : "Lawley" }
    { "_id" : ObjectId("56d7d730a2aed7160b3f06c8"), "email" : "content", "first_name" : "xu", "last_name" : "yundong" }
    > db.user.find({'email': {$regex: '^(.*@.*)$'}})
    { "_id" : ObjectId("56d7ced2a2aed7154cef7b03"), "email" : "[email protected]", "first_name" : "Ross", "last_name" : "Lawley" }
    ```

    这个是使用正则,匹配 @符号
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   983 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 19:03 · PVG 03:03 · LAX 12:03 · JFK 15:03
    ♥ Do have faith in what you're doing.