QUOTE(Mike @ Apr 2 2007, 06:42 AM)

Yeah, I considered using Javascript at about 4:30am when I realized it was a bit intensive. The problem is that it couldn't perform any replacements that were contained within any actual html tags, since links like:
CODE
<a href="http://www.americasdebate.com/forums/index.php">
... would have ended up being ...
CODE
<a href="http://www.<span class="redact">america</span>s<span class="redact">debate</a>.com/forums/index.php">
...especially when you consider my poor grasp of both regular expressions, and JavaScript. I'm not sure if your code covers it (for the same lack of regex and js skills), and I wasn't about to rewrite it in the middle of the night. An exercise in hair-pulling indeed. Heh!
The way you did it worked very nicely, indeed. Just to finish my earlier post, the replacement function does need some help to avoid tags. In case anyone's interested, here's a fleshed-out JavaScript workalike, after replacing ellipses and debugging in Firefox and Safari:
CODE
// str.replaceText( regExp, replacement ) protects markup from replacements
String.prototype.replaceText = function( x, r ){ //same input as replace()
return this.replace( /(^|>)([^<>]+)(<|$)/g, function(m,a,b,c){
return [ a, b.replace(x,r), c ].join('');
});
}
// str.redact() is hard-wired, but could be generalized for hilite, etc.
// With an Ajax style class switcher, the effect could toggle off and on.
String.prototype.redact = function( w ){
return this.replaceText(
new RegExp( '\\b(' + w.replace( /(^\W+|\W+$)/g, '' ).replace( /\W+/g, '|' ) + ')' , 'gi' ),
'<span style="color:black; background-color:black">$1</span>'
);
}
// Call document.redact() from an event handler like window.onload()
// The list is cut-and-paste from Jaime's post plus a few apostrophes.
document.redact = function(){
this.body.innerHTML=this.body.innerHTML.redact([
'america, army, ballot, battle, british, budget, bush, cheney, citizen',
'combat, commonwealth, conservative, constitution, debate, democracy',
'democrat, democratic, election, environment, equal, federal, freedom',
'gonzalez, government, guantanamo, homeland, honest, immunity, independent',
'intelligence, iran, iraq, justice, liberal, libertarian, liberty, marines',
'navy, news, president, private, protest, public, republic, republican',
'rove, rumsfeld, sanction, security, sovereign, state, surveillance',
'terror, truth, united, vote'
].join(', '));
}
// It's probably safer to redact through a body onload attribute
// or an Ajax lib's addEventListener() emulator,
// but the following works in simple test pages
window.onload = function(){
document.redact();
}
Happy pranking!

Edited to add:
The replaceText() method above protects most HTML code within angle brackets, but does not try to avoid adding tags within
textarea and
pre elements. I have a script (its also standard fare for Ajax libraries) that fixes the problem by removing all (or specified) markup within all such elements. Feel free to PM me if you need it.