On 6 Jan 2012 21:12, <greg.zol...@aviall.com> wrote: > Say I have a string in a file like this: > > require(["a","foo/b","foo/c"], function(){...}) > > What I want to do is replace all the "foo" with "bar" so the final product > looks like this: > > require(["a","bar/b","bar/c"], function(){...}) > > With replaceregexp the best I've been able to get was below using regexp > like "require\(\s*\[(.*)foo/([^\]]*)\]" > > require(["a","foo/b","bar/c"], function(){...}) > > (I can't just do a global replace on "foo" because I only want to do the > replacement in this "require" context.) > > Any ideas?
Run your regexp over the file twice? Second pass will catch the foo that was left over the first time. Andy.