Page 1 of 1

weird Replace results...

Posted: Mon May 10, 2004 4:10 pm
by cow
I'm trying to insert a single line in about 50 HTML files but I'm getting weird results when I use the Replace All command.

I'm trying to change this:
<li>&nbsp;<a href="/courses.html">Courses</a></li>

To this:
<li>&nbsp;<a href="/courses.html">Courses</a></li>
<li>&nbsp;<a href="/prizes.html">Prizes</a></li>

Using this in the Replace command (Conditions: Text, Regular Expression; Scope: Active document):
Find what: <li>&nbsp;<a href="/courses.html">Courses</a></li>\n
Replace with: <li>&nbsp;<a href="/courses.html">Courses</a></li>\n<li>&nbsp;<a href="/prizes.html">Prizes</a></li>

I get this when I click the Replace All button:
<li><li>&nbsp;<a href="/courses.html">Courses</a></li>
nbsp;<a href="/courses.html">Courses</a></li>
<li><li>&nbsp;<a href="/courses.html">Courses</a></li>
nbsp;<a href="/prizes.html">Prizes</a></li>

I've used the Replace command many times with &nbsp; and I've never had any problems. Any ideas?!?

Posted: Mon May 10, 2004 4:48 pm
by ben_josephs
When you're using regular expressions, an & in the replacement expression represents the entire matched expression. Use \&.