Well. I'm not sure if JavaScript has regexps compatible with Perl but if it does you can use Text::Balanced for autogeneration of required regexp. Use this module to generate regexp and later just insert it into your JavaScript.
Comment on Re: Re: Re: Regex for escaping spaces in strings when there are quotes