@@ 24-40 (lines=17) @@ | ||
21 | } |
|
22 | return text.substr(idx); |
|
23 | }, |
|
24 | before: function(find, returnAll = true, inclusive = false, startAt = 0, forward = true){ |
|
25 | var text = this.toString(); |
|
26 | if (text == null) { return returnAll ? text : ''; } |
|
27 | if (text.length === 0) { |
|
28 | return text; |
|
29 | } |
|
30 | if (forward) { |
|
31 | var idx = text.indexOf(find, startAt); |
|
32 | }else { |
|
33 | idx = text.lastIndexOf(find, startAt); |
|
34 | } |
|
35 | if (idx === -1) { return returnAll ? text : ''; } |
|
36 | if (inclusive) { |
|
37 | idx += find.length; |
|
38 | } |
|
39 | return text.substr(0, idx); |
|
40 | }, |
|
41 | ||
42 | afterIndex: function(index, inclusive){ |
|
43 | var text = this.toString(); |
|
@@ 7-23 (lines=17) @@ | ||
4 | ||
5 | ||
6 | // other search functions |
|
7 | after: function(find, returnAll = true, inclusive = false, startAt = 0, forward = true){ |
|
8 | var text = this.toString(); |
|
9 | if (text == null) { return returnAll ? text : ''; } |
|
10 | if (text.length === 0) { |
|
11 | return text; |
|
12 | } |
|
13 | if (!forward) { |
|
14 | var idx = text.lastIndexOf(find, startAt); |
|
15 | }else { |
|
16 | idx = text.indexOf(find, startAt); |
|
17 | } |
|
18 | if (idx === -1) { return returnAll ? text : ''; } |
|
19 | if (!inclusive) { |
|
20 | idx += find.length; |
|
21 | } |
|
22 | return text.substr(idx); |
|
23 | }, |
|
24 | before: function(find, returnAll = true, inclusive = false, startAt = 0, forward = true){ |
|
25 | var text = this.toString(); |
|
26 | if (text == null) { return returnAll ? text : ''; } |