Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Does anyone know what this regex is used for? It line 26 of jQuery v1.11.0.

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

Its called as function here.

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);
            }
        });
like image 784
user3600619 Avatar asked Nov 26 '25 16:11

user3600619


2 Answers

If you checked the jQuery source (not the minified version as you did) you would have a chance to see the corresponding comment for this line:

// 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,
like image 152
zerkms Avatar answered Nov 28 '25 05:11

zerkms


Is part of the polyfill String.prototype.trim() method. Read more at 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 - Any whitespace character (space, tab, form feed, and so on). Read more on page 157 at Secrets of the javascript ninja

\uFEFF - UTF-8 byte order mark (BOM). Read more here.

\xA0 - non-breaking space in Latin1 (ISO 8859-1). Read more here.

like image 32
mario ruiz Avatar answered Nov 28 '25 06:11

mario ruiz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!