Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下のように、パターンを生の文字列として使用して再検索を実行したい。
m=re.search(r'pattern',string)
しかし、のような変数に「パターン」があるとしますpat='pattern'。未加工の検索を実行するにはどうすればよいですか?
pat='pattern'
この方法で生の入力を与えることができます。test は文字列変数です。
pat = """pat%s""" % test pattern = re.compile(pat, re.I | re.M) match = pattern.search(l)