replace_money: Replace Money With Words

View source: R/replace_money.R

replace_moneyR Documentation

Replace Money With Words

Description

Replaces money with word equivalents.

Usage

replace_money(
  x,
  pattern = "(-?)([$])([0-9,]+)(\\.\\d{2})?",
  replacement = NULL,
  ...
)

Arguments

x

The text variable.

pattern

Character money regex string to be matched in the given character vector.

replacement

A function to operate on the extracted matches or a character string which is a replacement for the matched pattern.

...

ignored.

Value

Returns a vector with the pattern replaced.

Examples

x <- c(
    NA, 
    '$3.16 into "three dollars, sixteen cents"', 
    "-$20,333.18 too", 'fff'
)

replace_money(x)
replace_money(x, replacement = '<<MONEY>>')

textclean documentation built on March 5, 2026, 9:06 a.m.