gsubfn is an R package used for string matching, substitution and parsing. A seemingly small generalization of gsub, namely allow the replacement string to be a replacement function, list, formula or proto object, can result in increased power and applicability. The resulting function, gsubfn is the namesake of this package.