Between takes two string params start and end which and returns value which is in middle of start and end part of input. You can chain to upper which with make result all upercase or ToLower which will make result all lower case or Get which will return result as it is
(start, end string)
| 74 | // chain to upper which with make result all upercase or ToLower which |
| 75 | // will make result all lower case or Get which will return result as it is |
| 76 | func (i *input) Between(start, end string) StringManipulation { |
| 77 | if (start == "" && end == "") || i.Input == "" { |
| 78 | return i |
| 79 | } |
| 80 | |
| 81 | input := strings.ToLower(i.Input) |
| 82 | lcStart := strings.ToLower(start) |
| 83 | lcEnd := strings.ToLower(end) |
| 84 | var startIndex, endIndex int |
| 85 | |
| 86 | if len(start) > 0 && strings.Contains(input, lcStart) { |
| 87 | startIndex = len(start) |
| 88 | } |
| 89 | if len(end) > 0 && strings.Contains(input, lcEnd) { |
| 90 | endIndex = strings.Index(input, lcEnd) |
| 91 | } else if len(input) > 0 { |
| 92 | endIndex = len(input) |
| 93 | } |
| 94 | i.Result = strings.TrimSpace(i.Input[startIndex:endIndex]) |
| 95 | return i |
| 96 | } |
| 97 | |
| 98 | // Boolean func returns boolean value of string value like on, off, 0, 1, yes, no |
| 99 | // returns boolean value of string input. You can chain this function on other function |