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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
+
|
// String
/*jslint esversion: 6*/
if (String.prototype.__grammalecte__ === undefined) {
String.prototype._count = function (sSearch, bOverlapping) {
if (String.prototype.grammalecte === undefined) {
String.prototype.gl_count = function (sSearch, bOverlapping) {
// http://jsperf.com/string-ocurrence-split-vs-match/8
if (sSearch.length <= 0) {
return this.length + 1;
}
let nOccur = 0;
let iPos = 0;
let nStep = (bOverlapping) ? 1 : sSearch.length;
while ((iPos = this.indexOf(sSearch, iPos)) >= 0) {
nOccur++;
iPos += nStep;
}
return nOccur;
}
String.prototype._isDigit = function () {
};
String.prototype.gl_isDigit = function () {
return (this.search(/^[0-9⁰¹²³⁴⁵⁶⁷⁸⁹]+$/) !== -1);
}
String.prototype._isLowerCase = function () {
};
String.prototype.gl_isLowerCase = function () {
return (this.search(/^[a-zà-öø-ÿ0-9-]+$/) !== -1);
}
String.prototype._isUpperCase = function () {
};
String.prototype.gl_isUpperCase = function () {
return (this.search(/^[A-ZÀ-ÖØ-ߌ0-9-]+$/) !== -1);
}
String.prototype._isTitle = function () {
};
String.prototype.gl_isTitle = function () {
return (this.search(/^[A-ZÀ-ÖØ-ߌ][a-zà-öø-ÿ'’-]+$/) !== -1);
}
String.prototype._toCapitalize = function () {
};
String.prototype.gl_toCapitalize = function () {
return this.slice(0,1).toUpperCase() + this.slice(1).toLowerCase();
}
String.prototype._expand = function (oMatch) {
};
String.prototype.gl_expand = function (oMatch) {
let sNew = this;
for (let i = 0; i < oMatch.length ; i++) {
let z = new RegExp("\\\\"+parseInt(i), "g");
sNew = sNew.replace(z, oMatch[i]);
}
return sNew;
}
String.prototype._trimRight = function (sChars) {
};
String.prototype.gl_trimRight = function (sChars) {
let z = new RegExp("["+sChars+"]+$");
return this.replace(z, "");
}
String.prototype._trimLeft = function (sChars) {
};
String.prototype.gl_trimLeft = function (sChars) {
let z = new RegExp("^["+sChars+"]+");
return this.replace(z, "");
}
String.prototype._trim = function (sChars) {
};
String.prototype.gl_trim = function (sChars) {
let z1 = new RegExp("^["+sChars+"]+");
let z2 = new RegExp("["+sChars+"]+$");
return this.replace(z1, "").replace(z2, "");
}
};
String.prototype.__grammalecte__ = true;
String.prototype.grammalecte = true;
}
|