From 4cad662b69be9fa62460a342e2fd1aa87a7bd548 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Fri, 20 Mar 2020 14:00:17 -0400 Subject: Improve brackets-within-brackets regex The horrible things people do to their patch subjects continue to amaze me. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index ae7e452..7b9d2cf 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -867,8 +867,8 @@ class LoreSubject: # Remove any brackets inside brackets while True: oldsubj = subject - subject = re.sub(r'^\s*\[([^\]]*)\[([^\]]*)\]', '[\\1\\2]', subject) - subject = re.sub(r'^\s*\[([^\]]*)\]([^\]]*)\]', '[\\1\\2]', subject) + subject = re.sub(r'^\s*\[([^\]]*)\[([^\[\]]*)\]', '[\\1\\2]', subject) + subject = re.sub(r'^\s*\[([^\]]*)\]([^\[\]]*)\]', '[\\1\\2]', subject) if oldsubj == subject: break -- cgit v1.2.3