I did something closely similar (parsing arbitrary content with regex) some 20 years ago. I read about my use case and my solution to that before I started coding. It was discouraged everywhere. I did not hear and coded it anyways. It was a bad idea. Lessons learned.
Been there, done that.