import re
regex = re.compile(r"^(?:[[:^print:][:cntrl:]\s]|GIF89.{0,20})*<\?(?:php)?\s*[[:punct:]\s]+scama\s*spotify\s*v1[\s\#]+facebook:\s*fb\.com\/amyr\.gov\.tn+[[:punct:]\s]+.{0,200}?want\s*to\s*save\s*rzlt\s*.html(?:[^>]+>\s*)?$", flags=re.IGNORECASE | re.DOTALL)
test_str = ("<?php \n"
"/*\n"
" $$$$$$\\ $$$$$$$\\ $$$$$$\\ $$\\ $$\\ $$$$$$$$\\ $$\\ $$\\ \n"
"$$ __$$\\ $$ __$$\\ $$ __$$\\ $$$\\ $$ | \\__$$ __|$$$\\ $$ |\n"
"$$ / $$ |$$ | $$ |$$ / $$ |$$$$\\ $$ | $$ | $$$$\\ $$ |\n"
"$$$$$$$$ |$$$$$$$ |$$ | $$ |$$ $$\\$$ |$$$$$$\\ $$ | $$ $$\\$$ |\n"
"$$ __$$ |$$ __$$< $$ | $$ |$$ \\$$$$ |\\______|$$ | $$ \\$$$$ |\n"
"$$ | $$ |$$ | $$ |$$ | $$ |$$ |\\$$$ | $$ | $$ |\\$$$ |\n"
"$$ | $$ |$$ | $$ | $$$$$$ |$$ | \\$$ | $$ | $$ | \\$$ |\n"
"\\__| \\__|\\__| \\__| \\______/ \\__| \\__| \\__| \\__| \\__|\n"
" \n"
"#==========================================#\n"
"# Scama Spotify v1 #\n"
"# facebook: fb.com/amyr.gov.tn #\n"
"#==========================================#\n\n"
" $$$$$$\\ $$$$$$\\ $$\\ $$$$$$\\ \n"
"$$ __$$\\ $$$ __$$\\ $$$$ | $$ __$$\\ \n"
"\\__/ $$ |$$$$\\ $$ |\\_$$ | $$ / $$ |\n"
" $$$$$$ |$$\\$$\\$$ | $$ | \\$$$$$$$ |\n"
"$$ ____/ $$ \\$$$$ | $$ | \\____$$ |\n"
"$$ | $$ |\\$$$ | $$ | $$\\ $$ |\n"
"$$$$$$$$\\ \\$$$$$$ /$$$$$$\\\\$$$$$$ |\n"
"\\________| \\______/ \\______|\\______/ \n"
"*/ \n"
"$aronxname = \"ARON-TN\";//<== Your Name \n"
"$aronxmail = \"moncompteperso12x0@gmail.com\"; //<== Your Email\n"
"$aronxsave = \"no\";//<== Write \"On\" if U want To Save RZlt .html !\n"
"?>\n")
matches = regex.finditer(test_str)
for match_num, match in enumerate(matches, start=1):
print(f"Match {match_num} was found at {match.start()}-{match.end()}: {match.group()}")
for group_num, group in enumerate(match.groups(), start=1):
print(f"Group {group_num} found at {match.start(group_num)}-{match.end(group_num)}: {group}")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html