I’m having trouble trying to write a query that returns all capital five letter codes in mongodb. I have this so far:
db.foo.find({f : {$regex : [/[A-Z]{5}/] } }).count()
It is not correct though as the result it returns is the size of the whole collection and I know there are at least 4000 entries not in upper-case. I haven’t had much experience using regular expressions so I’m struggling to see what’s going wrong.
I thihnk your regex is wrong, try: