I'm trying to use regex to parse bbcode, so far I could make this regex working fine
if re.search("(\[b\])", m, re.IGNORECASE):
r = re.compile(r"\[b\](?P<name>.*?)\[\/b\]", re.IGNORECASE)
m = r.sub(r'<b>\1</b>', m)
But on this case where I need to use multiple regular parentheses to catch font's styles and the contents wrapped inside font bbcode, for example
[f color="#fff" ...]string[/f]
, I can't get it working right as the output always ends up like this
string</font>
Here's my regex code. I don't know what I'm doing incorrectly here..
if re.search("(\[f .*?\])", m, re.IGNORECASE):
r = re.compile(r"\[f (?P<tag>.*?)\](?P<name>.*?)\[\/f\]", re.IGNORECASE)
m = r.sub(r'<font \g<tag>>\g<name></font>', m)