@@ 111-140 (lines=30) @@ | ||
108 | // check if ends with char of type |
|
109 | return str.charAt(str.length - 1).isOfCharRange(type); |
|
110 | }, |
|
111 | indexOfCharRange: function(type, startAt = null, forwards = true){ |
|
112 | var str = this; |
|
113 | ||
114 | // exit quickly if blank string |
|
115 | if (str == null || str.length === 0) { |
|
116 | return -1; |
|
117 | } |
|
118 | ||
119 | // find char of type |
|
120 | if (forwards) { |
|
121 | if (startAt == null) { |
|
122 | startAt = 0; |
|
123 | } |
|
124 | for (var c = startAt, cl = str.length;c<cl;c++){ |
|
125 | if (str.charAt(c).isOfCharRange(type)) { |
|
126 | return c; |
|
127 | } |
|
128 | } |
|
129 | }else { |
|
130 | if (startAt == null) { |
|
131 | startAt = str.length - 1; |
|
132 | } |
|
133 | for (var c = startAt;c >= 0;c--){ |
|
134 | if (str.charAt(c).isOfCharRange(type)) { |
|
135 | return c; |
|
136 | } |
|
137 | } |
|
138 | } |
|
139 | return -1; |
|
140 | }, |
|
141 | lastIndexOfCharRange: function(type){ |
|
142 | var str = this; |
|
143 | return str.indexOfCharRange(type, null, false); |
|
@@ 57-72 (lines=16) @@ | ||
54 | } |
|
55 | return true; |
|
56 | }, |
|
57 | isAllOfCharRange2: function(type1, type2, ifNoChars = false){ |
|
58 | var str = this; |
|
59 | ||
60 | // exit quickly if blank string |
|
61 | if (str == null || str.length === 0) { |
|
62 | return ifNoChars; |
|
63 | } |
|
64 | ||
65 | // find char of type |
|
66 | for (var c = 0, cl = str.length;c<cl;c++){ |
|
67 | if (!(str.charAt(c).isOfCharRange(type1) || str.charAt(c).isOfCharRange(type2))) { |
|
68 | return false; |
|
69 | } |
|
70 | } |
|
71 | return true; |
|
72 | }, |
|
73 | containsCharRange: function(type, startAt = 0, ifNoChars = false){ |
|
74 | var str = this; |
|
75 |