I want to transform a text like:
$$
foo
bar
$$
to
<% tex
foo
bar
%>
and $\alpha$
to <% tex \alpha %>
.
For the single line replace, I did this:
re.sub(r"\$(.*)\$", r"<% tex \1 %>", text)
...and it works fine.
Now, I added the multiline flag to catch the multiline one:
re.sub(r"(?i)\$\$(.*)\$\$", r"<% tex \1 %>", text)
...but it returns:
<% tex %>
foo
bar
<% tex %>
Why? I'm sure it's something trivial, but I can't imagine what.