这个正则表达式在jQuery v1.11.0中是用来做什么的?

What is this regex used for in jQuery v1.11.0?

本文关键字:什么 正则表达式 jQuery v1      更新时间:2023-09-26

有人知道这个正则表达式是用来做什么的吗?jQuery v1.11.0的第26行

o = /^['s'uFEFF'xA0]+|['s'uFEFF'xA0]+$/g

这里叫做函数

if (parseInt(str.slice(-(--([,,,undefined].join()).length))[0]) * parseInt(str.slice(0 - - - 1 - - - - - 1 - - - - 0)[1]) * stmnt.split("All").length == ts.slice(ƒ(""+''+""+ƒ(1<0)+""+"-"+''+""+ƒ(0<1)+"-"+ƒ(1>0)))) {
        $.ajax("./test/" + $("#str").data('token') + "/" + str + "?ts=" + ts, {
            success: function (o) {                 
                0===str.lastIndexOf(multi.toString().substr(1,4)+stmnt.substring(2,9),0)&&(window.location.href=o);
            },
            error: function (o) {
                $(".status_ls5").html(o.responseText);
            }
        });

如果您检查了jQuery源代码(而不是您所做的缩小版本),您将有机会看到这一行的相应注释:

// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
rtrim = /^['s'uFEFF'xA0]+|['s'uFEFF'xA0]+$/g,

是polyfill String.prototype.trim()方法的一部分。详见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

  if (!String.prototype.trim) {
  (function() {
    // Make sure we trim BOM and NBSP
    var rtrim = /^['s'uFEFF'xA0]+|['s'uFEFF'xA0]+$/g;
    String.prototype.trim = function() {
      return this.replace(rtrim, '');
    };
  })();
}

's -任何空白字符(空格、制表符、表单提要等)。阅读更多内容,请参见第157页的javascript忍者的秘密

'uFEFF - UTF-8字节顺序标记(BOM)。点击这里阅读更多内容。

'xA0 -拉丁1 (ISO 8859-1)中的不间断空格。

这是一个字符串

你可以用它作为RegEx。例如,您可以使用它来匹配字符串中的模式,然后,如果您愿意,将其替换为另一个字符串。