MCPcopy
hub / github.com/spicetify/cli / ReplaceOnce

Function ReplaceOnce

src/utils/utils.go:175–188  ·  view source on GitHub ↗
(str *string, pattern string, repl func(submatches ...string) string)

Source from the content-addressed store, hash-verified

173}
174
175func ReplaceOnce(str *string, pattern string, repl func(submatches ...string) string) {
176 re := regexp.MustCompile(pattern)
177 firstMatch := true
178 *str = re.ReplaceAllStringFunc(*str, func(match string) string {
179 if firstMatch {
180 firstMatch = false
181 submatches := re.FindStringSubmatch(match)
182 if submatches != nil {
183 return repl(submatches...)
184 }
185 }
186 return match
187 })
188}
189
190func ReplaceOnceWithPriority(str *string, patterns []string, repl func(index int, submatches ...string) string) {
191 for i, pattern := range patterns {

Callers 7

insertCustomAppFunction · 0.92
insertHomeConfigFunction · 0.92
insertSidebarConfigFunction · 0.92
insertExpFeaturesFunction · 0.92
insertVersionInfoFunction · 0.92
applyPatchesFunction · 0.92
StartFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected