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 3303800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:59:42+00:00 2026-05-17T20:59:42+00:00

Possible Duplicate: I'm looking for a regular expression to remove a given (x)HTML tag

  • 0

Possible Duplicate:
I'm looking for a regular expression to remove a given (x)HTML tag from a string

I have a long HTML file and I need to remove all the <img /> tags inside it and all the <a><img /></a> anchors.

What I’m thinking of is writing a PHP script that does the job. But each image and link has different number attributes so I don’t know how I can do this neatly. Any help would be strongly appreciated.

  • 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-17T20:59:42+00:00Added an answer on May 17, 2026 at 8:59 pm

    Thanks for the answers guys, this is the final solution that I was looking for.

    $text = preg_replace("/<a[^>]+\><img[^>]+\><\/a>\n/i", "", $text);
    
    $text = preg_replace("/<img[^>]+\>/i", "", $text);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Using C# regular expressions to remove HTML tags Extract Content from Div
Possible Duplicate: PHP preg_split string into letter pairs I have an string looking like
Possible Duplicate: Array slicing in Ruby: looking for explanation for illogical behaviour (taken from
Possible Duplicate: launch facebook app from other app I'm looking to see if it
Possible Duplicate: Unchecked exceptions in Java: Inherit from Error or RuntimeException? Looking at how
Possible Duplicate: C# Get control by name I have been looking around for an
Possible Duplicate: Python read a single character from the user I am looking to
Possible Duplicate: HTML 5 Geo Location Prompt in Chrome I've been looking at geolocation
Possible Duplicate: Oracle Search all tables all columns for string I'm looking for a
Possible Duplicate: Array slicing in Ruby: looking for explanation for illogical behaviour (taken from

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.