In other posts they explain how to match a MongoDB object id through a regex. I am looking the opposite: given a string, a regex that returns positive if it is not a valid mongo object id. In other words, I want to match everything that is not a mongodb object id.
I suppose it should be as easy as negate (?!) the regex, but I am not capable of making it right.
The regex should work in Javascript and Python3 (it could be two different regexs). I can accept a small loss of precision, if needed, and the string can have space but not newlines.
For example, a full name (James Bond
) should match positive, but not (45cbc4a0e4123f6920000002
)
More about Mongodb object Ids.
Thanks :-)