ncyoung.com
regular expression for closing image tags (google this)
This entry is in the following categories:
You can use this regular expression to find image tags that are not self closing and make them self closing. It will change:
<img src="spacer.gif" height="1" width="1">
to:
<img src="spacer.gif" height="1" width="1"/>
If you have:
<img src="spacer.gif" height="1" width="1"></img>
It will STILL change it to:
<img src="spacer.gif" height="1" width="1"/></img>
So in that case you can't just replace all.
It should be easy to re-purpose this for other tags that need to be made self closing.
The find term is:
<img ([^>]*)([^/])>
The replace term is:
<img \1\2/>
Dated: 05/16/2006
|
|
|