これは簡単な問題のように思えますが、明らかに私が見逃していることがあります。
カスタムタグ間で発生するコードのチャンクをHTML形式のコードに置き換えるように設計されたPython関数があります。
def subCode(text):
tags = re.findall('<<<mytag>>>.+?<<</mytag>>>', text, re.S)
for tag in tags:
match = re.search('>>>(.+?)<<<', tag, re.S)
replaced_code = replaceCode(match.group(1))
text = re.sub(tag, replaced_code, text, re.S|re.M)
return text
これは、次のように、タグの間にあるコードと一致します。
this is some
random text
<<<mytag>>>now this
is some
random code<<</mytag>>>
and this is text again
ただし、コードをフォーマットされた置換に置き換えるわけではなく、返される文字列は入力と同じです。私は何が欠けていますか?