If you need to create a complex regular expression, the best you might do is to debug it realtime onchange. One of the best free online tools for that is the REGex TESTER.
Via Regex Tester you might type a sample text and regular expression and dynamically see the matched substrings in few regex pattern types. Some flags are modifiable as well. At the bottom of the page you could also find some of the most popular regex conditions - email pattern, IP pattern etc. to be used for validation purposes.