The comments explain the problem: when passing unnamed arguments to gsub and sub, the variable goes third.
gsub
sub