I wanted to create a script that I could check .xhtml files for images and add alt tags if needed. While searching I found regular expressions and did man on glob but I'm unsure on where or what to search within awk and sed. What would be the best option to do the following:
<img class="something" width="something" height="something" src="folder/folder/image.png" />
<img id="something" src="folder/folder/file.png" />
I wanted the desired script to detect if an alt="" is present if not alt the file name.
End desired format:
<img class="something" width="something" height="something" src="folder/folder/image.png" alt="image"/>
<img id="something" src="folder/folder/file.png" alt="file"/>
I know it can be done but Im not sure where to read about it.
- Find
<imgwith the ending/> - Within
imgtag detectalt="" - if
alt=""is not present record name before file type and insert into""
<imgoccur outside the context of a valid image tag anywhere? How aboutalt=? Can tags span multiple lines? Complications like this are what make the problem impossible unless you place some additional restrictions on it.imgtags and make sure analttag is present