Skip to main content
Participating Frequently
January 23, 2012
Question

Regular Expression to find a tag with a missing attribute.

  • January 23, 2012
  • 1 reply
  • 1347 views

Here's my case, I'm trying to find an <img> tag that has a missing alt property.  how would I write that so that regex in Dreamweaver's find/replace, so that I don't have to review every individual <img> tag, verifying it has an alt property, until I find the tag I'm looking for?

I found a blog article that specifically addressed, this, but the regex didn't work:

<imgs+((width|height|border|class|id|src|usemap|hspace|vspace)=”[^"]+”s*)+/>

(I added the "/" at the end, since my document is XHTML)

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
January 31, 2012

JeremySeda wrote:

I found a blog article that specifically addressed, this, but the regex didn't work:

<imgs+((width|height|border|class|id|src|usemap|hspace|vspace)=”[^"]+” s*)+/>

(I added the "/" at the end, since my document is XHTML)

I haven't studied the regex in detail, but there are two obvious errors in it. There should be a backslash before the "s" after "img". Also, the forward slash that you added at the end should also be preceded by a backslash.

However, there is no need to go to such lengths to find missing "alt" text. In Dreamweaver, select Site > Reports. The dialog box that opens has options that will let you check for missing "alt" text in the current document, a specific folder, or even the whole site. Just click Run to get the report.