🐐 QVAERE
This commit is contained in:
@@ -1277,6 +1277,19 @@ class BuiltIn(Node):
|
||||
with open(path, "a") as f:
|
||||
f.write(content)
|
||||
return vtable, ValNul()
|
||||
case "QVAERE":
|
||||
pattern = params[0]
|
||||
text = params[1]
|
||||
if not isinstance(pattern, ValStr) or not isinstance(text, ValStr):
|
||||
raise CentvrionError("QVAERE requires two strings")
|
||||
try:
|
||||
matches = [
|
||||
ValStr(m.group(0))
|
||||
for m in re.finditer(pattern.value(), text.value())
|
||||
]
|
||||
except re.error as e:
|
||||
raise CentvrionError(f"Invalid regex: {e}")
|
||||
return vtable, ValList(matches)
|
||||
case _:
|
||||
raise NotImplementedError(self.builtin)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user