I have a query that searches text using a regex:
$filter = ['word' => new MongoDB\BSON\Regex("some text","i")];
$query = new MongoDB\Driver\Query($filter);
I now want to be able to search for text that does not contain the text: e.g. [^(some text)]
The first issue I'm having is that I can't get the NOT to work, it appears that ^
can only be used to force the start of the string. Here is what I tried to find text without the letter 'a' in:
$pat = '[^a]';
$filter = ['word' => new MongoDB\BSON\Regex($pat,"i")];
$query = new MongoDB\Driver\Query($filter);
That just returns all documents with a value set for 'word'
I also tried:
$pat = '^a';
But as expected, that returns all documents that start with an 'a'.
How can I get this to work?