diff options
| author | ayyansea <ayyansea@gmail.com> | 2024-11-15 23:15:00 +0300 |
|---|---|---|
| committer | ayyansea <ayyansea@gmail.com> | 2024-11-15 23:15:00 +0300 |
| commit | c0d7adb1a1b28b6b1de9ccd95d4963a8342ccdbc (patch) | |
| tree | 1de133ef28e1f846e58bdaa49beb17dd1857424c /internal/split/split.go | |
| parent | cc7f4da0796fbd76301173dede6791f4525bf8e0 (diff) | |
feat: add Filters
Diffstat (limited to 'internal/split/split.go')
| -rw-r--r-- | internal/split/split.go | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/internal/split/split.go b/internal/split/split.go deleted file mode 100644 index 65e1a14..0000000 --- a/internal/split/split.go +++ /dev/null @@ -1,44 +0,0 @@ -package split - -import ( - "strings" -) - -func checkArrayElementsEmpty(array []string) bool { - for _, str := range array { - if str != "" { - return false - } - } - return true -} - -func NewArrayWithSplit(initialArray []string, index int, token string, delimeter string) (result []string) { - split := strings.Split(token, delimeter) - splitLength := len(split) - - /* - When a token only consists of delimeter * N (N >= 0), - the resulting split consists of N empty elements. - Here we check if it is so and essentialy remove that token - from resulting array. - */ - splitIsEmpty := checkArrayElementsEmpty(split) - if splitIsEmpty { - result = append(initialArray[:index], initialArray[index+1:]...) - return result - } - - if splitLength > 1 { - if split[splitLength-1] == "" { - split = split[:splitLength-1] - } - - result = append(initialArray[:index], append(split, initialArray[index+1:]...)...) - } - if splitLength == 1 { - result = initialArray - } - - return result -} |
