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

  • SEARCH
  • Home
  • 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 8809501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:53:28+00:00 2026-06-14T02:53:28+00:00

I am using a rather simple regex to make links posted to change that

  • 0

I am using a rather simple regex to make links posted to change that area to say [LINK REMOVED]. What I want to do though, is to completely clear out anything they typed with one space, instead of just removing the link itself.

I am not that good with regexes yet, so I could really use the help! Here’s what I have at the moment.

$comment = preg_replace('%[a-zA-Z0-9\-\.]+\.
(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)%', '[LINK REMOVED]', $comment);
  • 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-06-14T02:53:29+00:00Added an answer on June 14, 2026 at 2:53 am

    You could either consume the whole comment in the match:

    $comment = preg_replace('%^.*[a-z0-9.-]+\.(com|org|net|mil|edu).*$%is', ' ', $comment);
    

    Or simply use preg_match and delete the comment yourself:

    if(preg_match('%[a-z0-9.-]+\.(com|org|net|mil|edu)%i', $comment))
        $comment = ' ';
    

    Note that I also slightly optimized the regex by using the case-insensitive modifier i and removing unnecessary escapes in the character class (for this to work, the hyphen has to be at the end of the character class though).

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

Sidebar

Related Questions

Using EF we can use LINQ to read data which is rather simple (especially
I want to write an application using openstreetmaps rather than mkmapview, but I'm not
i have a propably rather simple question: I'm using the following script to read
I'm using the igraph package in R to do something rather simple: Calculate the
I'm not using any MVC framework and my application structure is rather simple... actions/
I built a rather simple application in Python 3.1 using PyQt4. Being done, I
I wanna make this rather simple to ask so I can hope for a
I am using NSIS to create install and uninstall wizards to my rather simple
I'm stuck on a RegEx problem that's seemingly very simple and yet I can't
This is a very basic or rather simple question. In my code, I'm using

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.