A workaround for lacking textarea "SAR" technologies
Given the browser-as-wordprocessor hype, with your collaboration and flash embed capability and other "features," what happened to search and replace?
I wrote a small bookmarklet that finds all <textarea> elements in the current document and inserts 3 anonymous new elements:
- a "search" box that takes a regular expression,
- a "replace" box that takes a replacement string (with optional $1, etc.), and
- a button to execute the "SAR"
Here it is: Search-N-Replace
And here's a textarea to try it on:
The unobfuscated source:
var D=document;
var tas=D.getElementsByTagName('textarea');
var i=tas.length;
while (i > 0) {
(function(ta) {
var f=ta.parentNode;
var s=D.createElement('input');
var r=D.createElement('input');
var b=D.createElement('input');
b.value='replace';
s.type=r.type='text';
b.type='button';
b.onclick=function(){
ta.value=ta.value.replace(new RegExp(s.value,'g'),r.value);
};
f.insertBefore(s,ta);
f.insertBefore(r,ta);
f.insertBefore(b,ta);
})(tas[--i]);
}
Update: At least one of these has search & replace now. "I apologize for any difficulties this may have caused you."