ex-reg-ex문제
#!/usr/bin/python3
from flask import Flask, request, render_template
import re
app = Flask(__name__)
try:
FLAG = open("./flag.txt", "r").read() # flag is here!
except:
FLAG = "[**FLAG**]"
@app.route("/", methods = ["GET", "POST"])
def index():
input_val = ""
if request.method == "POST":
input_val = request.form.get("input_val", "")
m = re.match(r'dr\w{5,7}e\d+am@[a-z]{3,7}\.\w+', input_val)
if m:
return render_template("index.html", pre_txt=input_val, flag=FLAG)
return render_template("index.html", pre_txt=input_val, flag='?')
app.run(host="0.0.0.0", port=8000)
m = re.match(r'dr\w{5,7}e\d+am@[a-z]{3,7}.\w+', input_val)
dr: "dr"로 시작해야 합니다.
\w{5,7}: 5자에서 7자 사이의 영숫자 문자(알파벳 대소문자 및 숫자) 로 구성되어야 합니다.
e: "e"로 이어져야 합니다.
\d+: 하나 이상의 숫자가 뒤따라야 합니다.
am@: "am@"로 이어져야 합니다.
[a-z]{3,7}: 3자에서 7자 사이의 소문자 알파벳이 이어져야 합니다.
.: "." 문자로 이어져야 합니다.
\w+: 하나 이상의 영숫자 문자로 끝나야 합니다.