StringUtils: Add a utility for checking if a string is a valid regex
[lhc/web/wiklou.git] / resources / src / mediawiki.RegExp.js
index 91cdc2d..258bc2c 100644 (file)
@@ -1,22 +1,5 @@
-( function ( mw ) {
-       /**
-        * @class mw.RegExp
-        */
-       mw.RegExp = {
-               /**
-                * Escape string for safe inclusion in regular expression
-                *
-                * The following characters are escaped:
-                *
-                *     \ { } ( ) | . ? * + - ^ $ [ ]
-                *
-                * @since 1.26
-                * @static
-                * @param {string} str String to escape
-                * @return {string} Escaped string
-                */
-               escape: function ( str ) {
-                       return str.replace( /([\\{}()|.?*+\-^$\[\]])/g, '\\$1' ); // eslint-disable-line no-useless-escape
-               }
-       };
-}( mediaWiki ) );
+( function () {
+       mw.RegExp = {};
+       // Backwards-compatible alias; @deprecated since 1.34
+       mw.log.deprecate( mw.RegExp, 'escape', mw.util.escapeRegExp, 'Use mw.util.escapeRegExp() instead.', 'mw.RegExp.escape' );
+}() );