From c30b102458eaa2e1aa3bc95669cb127ea2e12db0 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 4 Jan 2023 13:02:16 -0800 Subject: [PATCH] Use re.sub instead of looping over re.findall --- manimlib/utils/tex.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manimlib/utils/tex.py b/manimlib/utils/tex.py index 294be247..719d228a 100644 --- a/manimlib/utils/tex.py +++ b/manimlib/utils/tex.py @@ -18,8 +18,7 @@ def num_tex_symbols(tex: str) -> int: rf"(\\{s})" + r"(\{\w+\})?(\{\w+\})?(\[\w+\])?" for s in ["begin", "end", "phantom"] ) - for tup in re.findall(pattern, tex): - tex = tex.replace("".join(tup), " ") + tex = re.sub(pattern, "", tex) # Progressively count the symbols associated with certain tex commands, # and remove those commands from the string, adding the number of symbols