Fix regex for numbers to support negative numbers
This commit is contained in:
@@ -91,10 +91,10 @@ func (p *RegexProcessor) ProcessContent(content string, pattern string, luaExpr
|
|||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
replacement := `\d*\.?\d+`
|
replacement := `-?\d*\.?\d+`
|
||||||
return parts[1] + replacement
|
return parts[1] + replacement
|
||||||
})
|
})
|
||||||
pattern = strings.ReplaceAll(pattern, "!num", `"?(\d*\.?\d+)"?`)
|
pattern = strings.ReplaceAll(pattern, "!num", `"?(-?\d*\.?\d+)"?`)
|
||||||
pattern = strings.ReplaceAll(pattern, "!any", `.*?`)
|
pattern = strings.ReplaceAll(pattern, "!any", `.*?`)
|
||||||
repPattern := regexp.MustCompile(`!rep\(([^,]+),\s*(\d+)\)`)
|
repPattern := regexp.MustCompile(`!rep\(([^,]+),\s*(\d+)\)`)
|
||||||
// !rep(pattern, count) repeats the pattern n times
|
// !rep(pattern, count) repeats the pattern n times
|
||||||
|
Reference in New Issue
Block a user