1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-11 19:06:50 +02:00
TableFilter/src/string.js
2014-10-26 12:42:34 +11:00

50 lines
981 B
JavaScript

/**
* String utilities
*/
(function(window, TF){
'use strict';
TF.Str = {};
TF.Str.lower = function(text){
return text.toLowerCase();
};
TF.Str.upper = function(text){
return text.toUpperCase();
};
TF.Str.trim = function(text){
if (text.trim){
return text.trim();
}
return text.replace(/^\s*|\s*$/g, '');
};
TF.Str.isEmpty = function(text){
return this.trim(text) === '';
};
TF.Str.rgxEsc = function(text){
function escape(e){
var a = new RegExp('\\'+e,'g');
text = text.replace(a,'\\'+e);
}
var chars = ['\\','[','^','$','.','|','?','*','+','(',')'];
for(var e=0; e<chars.length; e++){
escape(chars[e]);
}
return text;
};
TF.Str.matchCase = function(text, mc){
if(!mc){
return this.lower(text);
}
return text;
};
})(this, this.TF);