Interlude: Tools for debugging and visualization
As your regexp gets complicated, it can get difficult to debug when you run into issues. Building your regexp step by step from scratch and testing against input strings will go a long way in correcting the problem. To aid in such a process, you could use various online regexp tools.
regex101
regex101 is a popular site to test your regexp. You'll have to first choose the flavor as JavaScript. Then you can add your regexp, input strings, choose flags and an optional replacement string. Matching portions will be highlighted and explanation is offered in separate panes.
The below image is a screenshot from this link — regex101: /ab{0,2}c/g
Do explore all the features provided by the site. There's a quick reference and other features like link sharing, code generator, quiz, cheatsheet, etc. regexr is another site that offers similar functionality.
regulex
Another useful tool is jex: regulex which converts your regexp to a railroad diagram, thus providing a visual aid to understanding the pattern.
The below image is a screenshot from this link — regulex: /\bpar(en|ro)?t\b/
debuggex is another site that offers similar functionality.
regexcrossword
For practice, regexcrossword is often recommended. This site only supports the JavaScript flavor. See regexcrossword: howtoplay for help.
Summary
This chapter briefly presented online tools that can help you with understanding and interactively solving/debugging regular expressions. Syntax and features can vary, sometimes significantly, between various tools and programming languages. So, ensure that the program you are using supports the flavor of regular expressions you are using.