Skip to contents

This function redacts email addresses in a given text by replacing them with a specified string.

Usage

redact_email_addresses(text, replace_with = NULL)

Arguments

text

The text in which email addresses are to be redacted.

replace_with

A string to replace email addresses with. It can be either a whole word pattern or a single character. Default is NULL, which uses the default value specified in the `replace_pattern()` function.

Value

A character vector with redacted email addresses.

Examples

text <- "Hello, my email address is john.doe@gmail.com. Please don't share it with anyone."
redacted_text <- redact_email_addresses(text)
cat(redacted_text)
#> Hello, my email address is [REDACTED]. Please don't share it with anyone.