Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:18:54+00:00 2026-05-15T23:18:54+00:00

How do I remove all email addresses and links from a string and replace

  • 0

How do I remove all email addresses and links from a string and replace them with “[removed]”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:18:55+00:00Added an answer on May 15, 2026 at 11:18 pm

    You can use preg_replace to do it.

    for emails:

    $pattern = "/[^@\s]*@[^@\s]*\.[^@\s]*/";
    $replacement = "[removed]";
    preg_replace($pattern, $replacement, $string);
    

    for urls:

    $pattern = "/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i";
    $replacement = "[removed]";
    preg_replace($pattern, $replacement, $string);
    

    Resources

    PHP manual entry: http://php.net/manual/en/function.preg-replace.php

    Credit where credit is due: email regex taken from preg_match manpage, and URL regex taken from: http://www.weberdev.com/get_example-4227.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer "echo 'hello' && ls" means : execute "ls" if "echo… May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer First, a small detour into HTTP HTTP is, essentially, the… May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer Hi I've managed to create drag&drop of a row in… May 16, 2026 at 10:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

How can I remove all triggers from my tables. I have many tables, but
I have a Git repository that I want to remove all previous commits from.
I'm looking for a javascript regex that will remove all content wrapped in quotes(and
Want to remove all 0 placed at the beginning of some variable. Some options:
I know that for parsing I should ideally remove all spaces and linebreaks but
I have two long list, one from a log file that contains lines formatted
I have a text which is made of lines and some of them look
I am working on a form in C# that is used for displaying information,
In using vim, when I start a comment with //, immediately after I type
Our company frequently issues important notices via e-mail as do many other companies do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.