Replacing with / in HTML links

Find, replace, find in files, replace in files, regular expressions

Replacing with / in HTML links

Postby loopdloop » Mon May 08, 2006 6:59 pm

In a list of HTML links like this, I'd like to replace all "\" inside the link with "/", but not inside any link text. I'm close, but there is something wrong with my looping.

before:
<a href="\html\constrbot.html">Link text to this page</a>
<a href="\html\consumer.html">Another link text</a>
<a href="\html\contact.html">More link text but with this character \ </a>
<a href="\html\croton.html">Also has the \ character</a>

desired result:
<a href="/html/constrbot.html">Link text to this page</a>
<a href="/html/consumer.html">Another link text</a>
<a href="/html/contact.html">More link text but with this character \</a>
<a href="/html/croton.html">Also has the \ character</a>

This script works for the first occurence, but then stops, and repeating the macro again selects the first line field (now corrected) and alerts "Search string not found!"

InsertMode
ColumnModeOff
HexOff
UnixReOff
Top
Loop
Find RegExp "href[~>]+"
IfFound
StartSelect
Find "\"
Replace All SelectText "/"
EndSelect
Else
ExitLoop
EndIf
EndLoop
Top
User avatar
loopdloop
Newbie
 
Posts: 5
Joined: Mon May 01, 2006 11:00 pm

Re: Replacing with / in HTML links

Postby mrainey56 » Mon May 08, 2006 7:30 pm

Added an EndIf !
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Replacing with / in HTML links

Postby loopdloop » Mon May 08, 2006 8:29 pm

Nice, thanks!
User avatar
loopdloop
Newbie
 
Posts: 5
Joined: Mon May 01, 2006 11:00 pm


Return to Find/Replace/Regular Expressions