2014-11-16 01:29:07 +01:00
|
|
|
/**
|
|
|
|
* String utilities
|
|
|
|
*/
|
|
|
|
|
2015-05-30 14:23:33 +02:00
|
|
|
export default {
|
|
|
|
|
|
|
|
lower(text){
|
|
|
|
return text.toLowerCase();
|
|
|
|
},
|
|
|
|
|
|
|
|
upper(text){
|
|
|
|
return text.toUpperCase();
|
|
|
|
},
|
|
|
|
|
|
|
|
trim(text){
|
|
|
|
if (text.trim){
|
|
|
|
return text.trim();
|
|
|
|
}
|
|
|
|
return text.replace(/^\s*|\s*$/g, '');
|
|
|
|
},
|
|
|
|
|
|
|
|
isEmpty(text){
|
|
|
|
return this.trim(text) === '';
|
|
|
|
},
|
|
|
|
|
|
|
|
rgxEsc(text){
|
2015-06-13 17:00:31 +02:00
|
|
|
let chars = /[-\/\\^$*+?.()|[\]{}]/g;
|
|
|
|
let escMatch = '\\$&';
|
|
|
|
return String(text).replace(chars, escMatch);
|
2015-05-30 14:23:33 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
matchCase(text, mc){
|
|
|
|
if(!mc){
|
|
|
|
return this.lower(text);
|
|
|
|
}
|
|
|
|
return text;
|
2014-11-16 01:29:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|