{"id":919,"date":"2017-05-26T18:43:17","date_gmt":"2017-05-26T18:43:17","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=919"},"modified":"2017-05-26T18:43:17","modified_gmt":"2017-05-26T18:43:17","slug":"negations-in-regex","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2017\/05\/26\/negations-in-regex\/","title":{"rendered":"Negations in Regex"},"content":{"rendered":"<p>If you are in the situations where you know what NOT to look for, but everything else is considered a match, then you need to negate the pattern and use something like this as explained on this <a href=\"http:\/\/www.perlmonks.org\/?node_id=188907\">permonks thread<\/a>.<\/p>\n<blockquote><p>\n^(?:(?!PATTERN).)*$<br \/>\n^(?:(?!nope|no|not|never|negate|negation).)*$\n<\/p><\/blockquote>\n<p>Here&#8217;s an example in Sublime Text.<br \/>\n<a href=\"http:\/\/shivdev.com\/blog\/wp-content\/uploads\/2017\/05\/regexNegations.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-920\" src=\"http:\/\/shivdev.com\/blog\/wp-content\/uploads\/2017\/05\/regexNegations-300x109.png\" alt=\"\" width=\"300\" height=\"109\" srcset=\"http:\/\/shivdev.com\/blog\/wp-content\/uploads\/2017\/05\/regexNegations-300x109.png 300w, http:\/\/shivdev.com\/blog\/wp-content\/uploads\/2017\/05\/regexNegations.png 515w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are in the situations where you know what NOT to look for, but everything else is considered a match, then you need to negate the pattern and use something like this as explained on this permonks thread. ^(?:(?!PATTERN).)*$ ^(?:(?!nope|no|not|never|negate|negation).)*$ Here&#8217;s an example in Sublime Text.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/919"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=919"}],"version-history":[{"count":1,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions"}],"predecessor-version":[{"id":921,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/919\/revisions\/921"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=919"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}