I have a regex that matches an "aliases" key that is an existing list in a markdown file, and captures the closing bracket as a group.
RE_ALIASES = re.compile(r'\s*---\n.*aliases:\s?\[.*(\]|\n\]).*\n---.*', re.DOTALL)
How do I replace that captured group with my own text?
i.e.,
---
...
aliases: [
hello,
world
]
---
...
should be
---
...
aliases: [
hello,
world,
inserted
]
---
...
In this case, the first group \n] is replaced by ,\n inserted\n]
re.sub