XHTML formatting for img tags

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
gwilly
Posts: 3
Joined: Fri Jul 25, 2003 7:01 pm

XHTML formatting for img tags

Post 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?
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Try
replacing
\(<img [^>]+\)>

with
\1/>

(depending on POSIX/non-Posix remove \ from search expression or not)
gwilly
Posts: 3
Joined: Fri Jul 25, 2003 7:01 pm

Post 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 "//>"
gwilly
Posts: 3
Joined: Fri Jul 25, 2003 7:01 pm

Post by gwilly »

Thanks Alot MudGuard.
I figured out the other part.
I just added a " into the find right before the >

\(<img [^>]+\)">
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

or a \([^/]\)
and \1\2

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