March 24, 2021
Sometimes you want to strip off gmail + additions from an email. You probably don’t want to store it this way because people should definitely be allowed to use + emails for filtering etc. but you may want to remove it to check for duplicates or other use cases. Here’s the regex for doing that.
const regex = /\+(.*)(?=@)/gm;
const strippedEmail = email.replace(regex, '');