2

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);
            }
        });
user3600619
  • 33
  • 1
  • 5
  • It's a regex equation. – royhowie May 05 '14 at 00:47
  • @Luxelin: not an "equation" as well – zerkms May 05 '14 at 00:47
  • @zerkms expression… you got me – royhowie May 05 '14 at 00:48
  • Your "Its called as function here" is confusing. How that piece of code is relevant to jquery's code? And where it's "called as function" there? – zerkms May 05 '14 at 00:53
  • 3
    Sure looks to me like the `o` in the top example is different from the `o` in the bottom example. Variable names can be reused without conflict in they're located in different variable scopes. It doesn't work to look at local variables in one scope and assume that the variable name represents the same data in all variable scopes. – cookie monster May 05 '14 at 00:56
  • Yeah, from first glance, none of the `o` variables actually seem to be RegEx but more, the data response from an ajax/XML/HTTP request. – brandito Aug 21 '18 at 04:42
  • @zerkms It's neither an expression or equation I thought? Since a RegEx expression, would be, a Regular Expression Expression. Reg = Regular, Ex = Expression – brandito Aug 21 '18 at 04:43
  • @royhowie RegEx, Regex & RegExp was just an abbreviation for Regular Expression from memory, I'd say you were closest calling it an equation. – brandito Aug 21 '18 at 04:45

3 Answers3

8

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,
zerkms
  • 249,484
  • 69
  • 436
  • 539
1

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.

Community
  • 1
  • 1
mario ruiz
  • 880
  • 1
  • 11
  • 28
0

That's a string.

And you can use it as RegEx. You can use it to match patterns in strings, for example, and then, if you want, replace it with another string.

Gonzalo.-
  • 12,512
  • 5
  • 50
  • 82