Put another way:
The Java API uses the Pattern java type. However, there is no way to
express a negative regex using the Pattern API (ie: !/^foo/i).
You can express the expanded $regex mongo condition by building it
yourself using a BasicDBObject, however there appears to be no way to
express a negative regex using the $regex mongo condition syntax.
Attempting to use the $not modifier causes the error shown above.
Since the Java driver seems to always use the expanded $regex syntax,
I don't see a way (using the Java driver) to do negative regex
queries.
Now that I read through the regex documentation more closely, I see
that there isn't an example using a negative regex.
Perhaps I should ask if Mongo's regular expressions support negative
expressions like:
* !/^abc/ - any string that does *NOT* begin with 'abc'
* !/.*abc$/ - any string that does *NOT* end with 'abc'
And if it does not, is there a way to express this otherwise?