1 | 'use strict'
|
2 | const templet = {
|
3 | cutString: function (original, before, after, index) {
|
4 | index = index || 0
|
5 | if (typeof index === "number") {
|
6 | const P = original.indexOf(before, index)
|
7 | if (P > -1) {
|
8 | if (after) {const f = original.indexOf(after, P + before.length)
|
9 |
|
10 |
|
11 | return (f>-1)? original.slice(P + before.toString().length, f) : ''
|
12 | } else {
|
13 | return original.slice(P + before.toString().length);
|
14 | }
|
15 | } else {
|
16 | return ''
|
17 | }
|
18 | } else {
|
19 | console.error("owo [sizeTransition:" + index + "不是一个整数!]")
|
20 | }
|
21 | },
|
22 | cutStringArray: function (original, before, after, index, inline) {
|
23 | let aa=[], ab=0;
|
24 | while(original.indexOf(before,index) > 0) {
|
25 | const temp = this.cutString(original, before, after, index)
|
26 | if (temp !== '') {
|
27 | if (inline) {
|
28 | if (temp.indexOf('\n') === -1) {
|
29 | aa[ab] = temp
|
30 | ab++
|
31 | }
|
32 | } else {
|
33 | aa[ab] = temp
|
34 | ab++
|
35 | }
|
36 | }
|
37 |
|
38 | index = original.indexOf(before, index) + 1
|
39 | }
|
40 | return aa;
|
41 | },
|
42 | trim: function (text) {
|
43 | if (text) {
|
44 | return text.replace(/(^\s*)|(\s*$)/g, "")
|
45 | } else {
|
46 | return ''
|
47 | }
|
48 | }
|
49 | }
|
50 |
|
51 | module.exports = templet |
\ | No newline at end of file |