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

问几个白痴问题

  •  
  •   SlipStupig · Apr 4, 2016 · 2853 views
    This topic created in 3864 days ago, the information mentioned may be changed or developed.
    mongodb 如何筛选制定条件的的数据并且删除掉,比如: email 列中长度小于 6 的,且不带 @符号的,该怎么写呢?
    4 replies  •  2016-04-05 17:17:55 +08:00
    imxieke
    imxieke
    Apr 5, 2016
    1
    正则表达式应该可以
    SlipStupig
    SlipStupig
    OP
    Apr 5, 2016
    2
    @imxieke 具体怎么写呢?
    imxieke
    imxieke
    Apr 5, 2016
    3
    @SlipStupig 抱歉 没有使用过 Mongodb 不是很清楚
    bwangel
    bwangel
    Apr 5, 2016❤️1
    4
    ```
    > 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   ·   Privacy   ·   Solana   ·   3921 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:05 · PVG 12:05 · LAX 20:05 · JFK 23:05
    ♥ Do have faith in what you're doing.