{"id":1000422,"date":"2007-02-19T10:26:19","date_gmt":"2007-02-19T15:26:19","guid":{"rendered":"http:\/\/www.elharo.com\/blog\/software-development\/2007\/02\/19\/not-substring-regular-expressions\/"},"modified":"2007-02-19T14:30:43","modified_gmt":"2007-02-19T19:30:43","slug":"not-substring-regular-expressions","status":"publish","type":"post","link":"https:\/\/www.elharo.com\/blog\/software-development\/perl\/2007\/02\/19\/not-substring-regular-expressions\/","title":{"rendered":"Not Substring Regular Expressions"},"content":{"rendered":"<p>I&#8217;m trying to devise a regular expression that will find all or most img tags that don&#8217;t have alt attributes. <code>&lt;img[^>]*\/><\/code> will find all the img elements (or at least most of them). And I can easily find those that do contain an alt attribute. However, I&#8217;m stumped when it comes to finding those that do <em>not<\/em> contain the substring <i>alt<\/i>. Any ideas?<br \/>\n<!--more--><\/p>\n<p>Note that this expression does not have to be perfect. I can live with some false positives and negatives. This is just meant to do a quick first pass over documents that will later be validated so any cases I miss will later be found, and nothing will be changed or replaced without human inspection first. This is a pure search, not a search and replace. <\/p>\n<p>It feels like I need some sort of not operator in regular expressions. What am I missing?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to devise a regular expression that will find all or most img tags that don&#8217;t have alt attributes. &lt;img[^>]*\/> will find all the img elements (or at least most of them). And I can easily find those that do contain an alt attribute. However, I&#8217;m stumped when it comes to finding those that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[410],"class_list":["post-1000422","post","type-post","status-publish","format-standard","hentry","category-perl","tag-flash"],"_links":{"self":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts\/1000422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/comments?post=1000422"}],"version-history":[{"count":0,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/posts\/1000422\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/media?parent=1000422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/categories?post=1000422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elharo.com\/blog\/wp-json\/wp\/v2\/tags?post=1000422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}