🐐 SVBSTITVE

This commit is contained in:
2026-04-22 09:30:58 +02:00
parent b9a1ed1bcc
commit 39218485c7
8 changed files with 136 additions and 2 deletions

View File

@@ -1290,6 +1290,17 @@ class BuiltIn(Node):
except re.error as e:
raise CentvrionError(f"Invalid regex: {e}")
return vtable, ValList(matches)
case "SVBSTITVE":
pattern = params[0]
replacement = params[1]
text = params[2]
if not isinstance(pattern, ValStr) or not isinstance(replacement, ValStr) or not isinstance(text, ValStr):
raise CentvrionError("SVBSTITVE requires three strings")
try:
result = re.sub(pattern.value(), replacement.value(), text.value())
except re.error as e:
raise CentvrionError(f"Invalid regex: {e}")
return vtable, ValStr(result)
case _:
raise NotImplementedError(self.builtin)