You can avoid headaches if you use a debugging tool listed in one of my posts.
Re: RegEx and Packaging Name Problem
In this tool, there is an options to save a config file, where you can monitor data structures as you run it line by line! Installing this module in Windows is very straight forward, just use ppm install!
This tool saved me not only time, but headache, heartburn...