forked from patriciogonzalezvivo/thebookofshaders
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_regex.py
More file actions
27 lines (20 loc) · 865 Bytes
/
Copy pathdebug_regex.py
File metadata and controls
27 lines (20 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import re
with open('toc-header.php', 'r', encoding='utf-8') as f:
content = f.read()
print(f"Content length: {len(content)}")
print(f"Content repr: {repr(content)}")
regex = r'<\?php\s+include\s*\(\s*["\']([^"\']+)["\']\s*\);\s*\?>'
match = re.search(regex, content, flags=re.DOTALL | re.IGNORECASE)
if match:
print("MATCH FOUND!")
print(f"Group 1: {match.group(1)}")
else:
print("NO MATCH")
# Try simpler regexes to see where it fails
print("Trying simple start...")
if re.search(r'<\?php', content): print("<?php found")
else: print("<?php NOT found")
print("Trying include...")
if re.search(r'include', content): print("include found")
print("Trying complex without tags...")
if re.search(r'include\s*\(\s*["\']([^"\']+)["\']\s*\);', content, flags=re.DOTALL): print("include statement found")