Clean up regex.go a little
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user