Hi Alan,
The last variant you quote should work. Your regex will require the ( to be escaped, and JavaScript string literal handling will have turned \( into ( by the time it reaches RegExp, so you will have to double escape the string literal as in \\( to let RegExp see it as \(. Cannot say why the regex will not match function names in fileContentAsStr, but perhaps that is a white space or case-sensitivity issue. Try something like this:
var re = new RegExp('function\\s+' + thisName + '\\s*\\(', 'gi');
For regex testing,
https://regex101.com/ is worth a visit — but keep in mind that the double escapes will have to be removed there.
Cheers --Hyde