Page 1 of 1

XHTML formatting for img tags

Posted: Fri Jul 25, 2003 7:06 pm
by gwilly
Hi,

I am currently trying to do a find and replace for img tags in my HTMl. EX:

type <img border="0" src="images/subsection.gif" width="13" height="13">

what I'm trying to do is replace the ">" with "/>" at the end.

I'm using <\img.*\([^ \>]+\)\(.*\)\([^/]\)"[0-9]+"> in my find
but I can't seem to get the correct replace syntax. Any suggestions?

Posted: Fri Jul 25, 2003 7:20 pm
by MudGuard
Try
replacing
\(<img [^>]+\)>

with
\1/>

(depending on POSIX/non-Posix remove \ from search expression or not)

Posted: Fri Jul 25, 2003 7:35 pm
by gwilly
Thanks alot!
That works like a champ. The only issue is when there is already "/>" at the end. Then it get's replaced with "//>"

Posted: Fri Jul 25, 2003 7:39 pm
by gwilly
Thanks Alot MudGuard.
I figured out the other part.
I just added a " into the find right before the >

\(<img [^>]+\)">

Posted: Fri Jul 25, 2003 7:49 pm
by MudGuard
or a \([^/]\)
and \1\2

(there are many ways to do it...)