2 Commits

Author SHA1 Message Date
b74e4724d4 Convert \n to \r?\n because of windows thank you windows :) 2025-10-26 17:04:39 +01:00
30246fd626 Fix logging the regex
It was adding backslashes and shit
2025-10-26 17:04:39 +01:00

View File

@@ -53,7 +53,7 @@ func ProcessRegex(content string, command utils.ModifyCommand, filename string)
processRegexLogger.Error("Error compiling pattern %q: %v", pattern, err)
return commands, fmt.Errorf("error compiling pattern: %v", err)
}
processRegexLogger.Debug("Compiled pattern successfully in %v", time.Since(patternCompileStart))
processRegexLogger.Debug("Compiled pattern successfully in %v. Pattern: %s", time.Since(patternCompileStart), pattern)
// Same here, it's just string concatenation, it won't kill us
// More important is that we don't fuck up the command
@@ -77,7 +77,7 @@ func ProcessRegex(content string, command utils.ModifyCommand, filename string)
processRegexLogger.Debug("Pattern complexity estimate: %d", patternComplexity)
if len(indices) == 0 {
processRegexLogger.Warning("No matches found for regex: %q", pattern)
processRegexLogger.Warning("No matches found for regex: %s", pattern)
processRegexLogger.Debug("Total regex processing time: %v", time.Since(startTime))
return commands, nil
}
@@ -335,6 +335,9 @@ func resolveRegexPlaceholders(pattern string) string {
pattern = strings.ReplaceAll(pattern, "!any", `.*?`)
resolveLogger.Debug("Replaced !any with non-greedy wildcard")
pattern = strings.ReplaceAll(pattern, "\n", "\r?\n")
resolveLogger.Debug("Added optional carriage return support for Windows line endings")
repPattern := regexp.MustCompile(`!rep\(([^,]+),\s*(\d+)\)`)
// !rep(pattern, count) repeats the pattern n times
// Inserting !any between each repetition