matches a delimited string with a pattern string the pattern string can contain "*" to match a single part, or "**" to match the rest of the string note that "**" may only appear at the end of the string
(pattern string, s string, delimiter string)
| 797 | // the pattern string can contain "*" to match a single part, or "**" to match the rest of the string |
| 798 | // note that "**" may only appear at the end of the string |
| 799 | func StarMatchString(pattern string, s string, delimiter string) bool { |
| 800 | patternParts := strings.Split(pattern, delimiter) |
| 801 | stringParts := strings.Split(s, delimiter) |
| 802 | pLen, sLen := len(patternParts), len(stringParts) |
| 803 | |
| 804 | for i := 0; i < pLen; i++ { |
| 805 | if patternParts[i] == "**" { |
| 806 | // '**' must be at the end to be valid |
| 807 | return i == pLen-1 |
| 808 | } |
| 809 | if i >= sLen { |
| 810 | // If string is exhausted but pattern is not |
| 811 | return false |
| 812 | } |
| 813 | if patternParts[i] != "*" && patternParts[i] != stringParts[i] { |
| 814 | // If current parts don't match and pattern part is not '*' |
| 815 | return false |
| 816 | } |
| 817 | } |
| 818 | // Check if both pattern and string are fully matched |
| 819 | return pLen == sLen |
| 820 | } |
| 821 | |
| 822 | func MergeStrMaps[T any](m1 map[string]T, m2 map[string]T) map[string]T { |
| 823 | rtn := make(map[string]T) |