Some examples: 1. test = foo("bar"); 2. test = foo("bar\""); 3. test = foo("bar") + bar("foo"); 4. test = foo("bar\"") + bar("foo"); I use: /foo\((")(.*)([^\\\])"\)/')/ Works for 1 and 2, but fails on 3 and for shouldn't match the + bar(...) part but is does.