# Text search and replace other text on the same line

I have code in a directory tree, with lots of sub-directories.

The function foo() takes two parameters,. which will generally be different for each call.

I want to add a third, which every caller has a variable in a variable named debug.

I want to recurse the directory tree, find every call to foo(x, y) or foo(a,b) or foo(1,2) and add the debug parameter, so that they become foo(x, y, debug), etc

I want a gratis Windows program that will all me to search a filename with wildcards and recurse through the directory tree, finding each line with foo( and changing each ) to , debug)

Any ideas?

You will fill the root directory path, check the In all sub-folders option, mark the Regular Expression option and fill the parameter as:
Find what: (foo$$.+?,.+?)$$
Replace with: \$1, debug\)