Regular Expression to find a tag with a missing attribute.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
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.

