Skip to content

Instantly share code, notes, and snippets.

@ch4nd4n
Created March 4, 2016 08:13
Show Gist options
  • Select an option

  • Save ch4nd4n/b16271354583cdd3c618 to your computer and use it in GitHub Desktop.

Select an option

Save ch4nd4n/b16271354583cdd3c618 to your computer and use it in GitHub Desktop.
Replace matching email with something else
str = "send your query to my@email.com or to another@provider.com"
matching_regex = /\S+@\S+\.\S+/
replace_with = "******"
str.gsub!(matching_regex, replace_with)
puts str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment