Tell me, please, the regular expression for making the rule:

The string does NOT contain СТРОКА1 .

Context: pull documents out of mongo, in one field it should be СТРОКА1 , and in another field СТРОКА1 should not be.

I do something like this:

 $q = 'СТРОКА1'; $regex = new \MongoRegex("/.*{$q}|ALL.*/i"); $regex_deny = new \MongoRegex("/[^({$q})]/i"); $documents = $document_manager->getRepository('MyDocument')->findBy(array( 'field1' => $regex, 'field2' => $regex_deny, )); 

Thank.

The question was originally posted on the site for students, teachers, and linguists.

    1 answer 1

     /^(?!(.*СТРОКА1))/ 

    those. in your case, as I understand it:

     /^(?!(.*{$q}))/ 

    Demo

    • Thank you for what you need! - Michael Popravko
    • Our site is different from social networks. It helps to solve applied problems. Therefore, we use comments only on the case - to clarify the problem, to give constructive criticism or add useful information. To thank the author of the answer, vote for the answer or mark it as a decision. ru.stackoverflow.com/help/someone-answers - Crantisz