When fiddling around with the regexps in my DNS Debug module I almost went mad before finding this tool: https://www.debuggex.com/.
I just want to give them the credit they are worth. They make understanding and following a RegEx understandable.
You enter your regexp’s and some sample data and they visualize what is happening.