Is it possible to take this:
a=[[do end workspace.Part["Child 1"].Object.child2["thing"]remove() do end]]
a=a:gsub("%.%a+","{F}%0{F}")
a=a:gsub('(%[%s*([\'"]?).*%2%s*%]):remove%(%)','{F}%1{F}:remove()')
a=a:gsub('{F}%s*{F}','')
a=a:gsub('{F}.-{F}','filterremove(%0)')
Output: do end filterremove(Workspace.Part["Child 1"].Object.child2["thing"]) do end
and use only one gsub to have the same result, rather than two? regardless of the combination of x.y, x[y], [x][y], etc.
a=a:gsub("(.*)%:remove%(%)", "filterremove(%1)")<- works fine.