regexpEscape( s ) {

        return sourceEscape(
            s
                .replace( /\\/g, "\\\\" )   // backslash
                .replace( /\//g, "\\/" )    // closing slash
                .replace( /]/g, "\\]" )     // closing bracket
                .replace( /\^/g, "\\^" )    // caret
                .replace( /-/g, "\\-" ),     // dash
        );

    }
Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.

For portability, we also escape all control and non-ASCII characters.