Replacing brackets in a string

Perhaps use Regex captures like this? Strings · The Julia Language

julia> replace.(["MyFunction[x] = ...", "a = MyFunction[2]"], 
                 r"MyFunction\[(?<x>\w+)\]" => s"MyFunction(\g<x>)")
2-element Vector{String}:
 "MyFunction(x) = ..."
 "a = MyFunction(2)"