Clean up regex.go a little

This commit is contained in:
2025-03-27 23:02:33 +01:00
parent cc30c2bdcb
commit bf72734b90
4 changed files with 24 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ package utils
import (
"fmt"
"modify/logger"
"sort"
)
type ReplaceCommand struct {
@@ -13,6 +14,12 @@ type ReplaceCommand struct {
func ExecuteModifications(modifications []ReplaceCommand, fileData string) (string, int) {
var err error
sort.Slice(modifications, func(i, j int) bool {
return modifications[i].From > modifications[j].From
})
logger.Trace("Applying %d replacement commands in reverse order", len(modifications))
executed := 0
for _, modification := range modifications {
fileData, err = modification.Execute(fileData)