webcraft-ai-backend / deploy_tmp /debug_regex.py
3ssem0
fix: configuration error - aligned entry point to app.py and enforced LF/BOM-less encoding
ec47953
Raw
History Blame Contribute Delete
905 Bytes
import re
content = """
Blockly.Blocks['ui_section'] = {
init: function() {
// ...
this.setPreviousStatement(true, "basic_body_element");
}
};
"""
# Pattern 1: Original (Suspected broken)
p1 = re.compile(r"\.setPreviousStatement\s*\(\s*true(?:,\s*(?:\[(.*?)\]|[\"\'](.*?)\"\']))?\s*\)", re.DOTALL)
# Pattern 2: Simplified
p2 = re.compile(r"\.setPreviousStatement\s*\(\s*true(?:,\s*(?:\[(.*?)\]|[\"'](.*?)[\"']))?\s*\)", re.DOTALL)
# Pattern 3: Very Simple
p3 = re.compile(r"\.setPreviousStatement\s*\(\s*true\s*,\s*[\"'](.*?)[\"']", re.DOTALL)
def test(name, pattern, text):
m = pattern.search(text)
if m:
print(f"{name}: MATCH! Groups: {m.groups()}")
else:
print(f"{name}: NO MATCH")
print("--- Testing ui_section ---")
test("Pattern 1", p1, content)
test("Pattern 2", p2, content)
test("Pattern 3", p3, content)