{"id":84,"date":"2011-06-14T10:17:18","date_gmt":"2011-06-14T15:17:18","guid":{"rendered":"http:\/\/www.marcblase.com\/blog\/?p=84"},"modified":"2011-08-24T12:55:04","modified_gmt":"2011-08-24T17:55:04","slug":"regex-reverse-matching","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2011\/06\/regex-reverse-matching\/","title":{"rendered":"Regex Reverse Matching"},"content":{"rendered":"<p>The fact that regex doesn&#8217;t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds:<\/p>\n<pre lang=\"javascript\">\r\n^((?!mystring).)*$\r\n<\/pre>\n<p>The regex above will match any string, or line without a line break, not containing the (sub) string &#8216;mystring&#8217;. This is not something regex is &#8220;good&#8221; at (or should do), but still, it is possible.<\/p>\n<p><small>Thanks to a poster at <a href=\"http:\/\/stackoverflow.com\/questions\/406230\/regular-expression-to-match-string-not-containing-a-word\">stackoverflow.com<\/a> for the solution.<\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The fact that regex doesn&#8217;t support inverse matching is not entirely true. You can mimic this behavior by using negative look-arounds: ^((?!mystring).)*$ The regex above will match any string, or line without a line break, not containing the (sub) string &#8216;mystring&#8217;. This is not something regex is &#8220;good&#8221; at (or should do), but still, it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[22],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-coding","tag-regex"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=84"}],"version-history":[{"count":4,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":124,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/84\/revisions\/124"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}