mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-17 16:10:04 +01:00
Code refactoring
This commit is contained in:
parent
d903fba533
commit
a0639cfe1d
10 changed files with 7871 additions and 302 deletions
46
src/string.js
Normal file
46
src/string.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* 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){
|
||||
return text.replace(/(^[\s\xA0]*)|([\s\xA0]*$)/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 || {});
|
||||
Loading…
Add table
Add a link
Reference in a new issue