-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring-plus.js
35 lines (30 loc) · 989 Bytes
/
string-plus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
String.prototype.withoutAccent = function(){
var accent = [
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o
/[\331-\334]/g, /[\371-\374]/g, // U, u
/[\321]/g, /[\361]/g, // N, n
/[\307]/g, /[\347]/g, // C, c
];
var noaccent = ['A','a','E','e','I','i','O','o','U','u','N','n','C','c'];
var str = this;
for(var i = 0; i < accent.length; i++){
str = str.replace(accent[i], noaccent[i]);
}
return str;
}
String.prototype.without = function (pString){
var str = this;
return str.replace(pString, "");
}
String.prototype.clean = function (){
var str = this;
var strip_LineFeed =/(?:\r\n|\r|\n|\t){2,}/g;
return str.replace(strip_LineFeed,"").replace(' ', ' ');
}
String.prototype.isNumber = function (){
var str = this;
return !isNaN(str);
}