}
// }}}
+// {{{ function RegExp.escape()
+
+RegExp.escape = function(text) {
+ if (!arguments.callee.sRE) {
+ var specials = [
+ '/', '.', '*', '+', '?', '|',
+ '(', ')', '[', ']', '{', '}',
+ '\\', '^' , '$'
+ ];
+ arguments.callee.sRE = new RegExp(
+ '(\\' + specials.join('|\\') + ')', 'g'
+ );
+ }
+ return text.replace(arguments.callee.sRE, '\\$1');
+}
+
+// }}}
/***************************************************************************
* POPUP THINGS
// display an autocomplete row : blabla (nb of found matches)
function make_format_autocomplete(block) {
return function(row) {
- regexp = new RegExp('(' + block.value + ')', 'i');
+ regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i');
name = row[0].replace(regexp, '<strong>$1</strong>');
if (row[1] == 1) {
return name;