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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:11:14+00:00 2026-05-20T00:11:14+00:00

I currently have a perl script that imports HTML and converts it to plain

  • 0

I currently have a perl script that imports HTML and converts it to plain text. I am using HTML::TagFilter to remove all the HTML tags and it is working almost perfectly except we’ve run into one issue. When the HTML contains non-stand HTML tags such as the “caption” in the example input below those tags aren’t being removed:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam pulvinar, odio ut gravida fringilla, tellus mi ultrices felis, quis porta lacus sem ut lacus. Vestibulum massa justo, tristique id aliquet in, dapibus eu leo. Nam sapien risus, dictum et porttitor quis, egestas quis dui. Ut nec nisl felis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

<a href="http://www.domain.com/image.jpg"><img class="sample-image-class" title="Sample Title" src="http://www.domain.com/image.jpg" alt="Sample Alt" width="225" height="300" /></a>

Sample Caption

In hac habitasse platea dictumst. Duis imperdiet bibendum dolor ut ullamcorper. Suspendisse dui erat, facilisis sed aliquet non, elementum eu urna. Donec non nisi vel augue gravida imperdiet sed id tortor. Maecenas ullamcorper velit non dui imperdiet hendrerit.

What I need help with is a simple Perl regex to remove this content completely. I’ve tried a bunch of different approaches but nothing seems to be working. What I’m looking for is something like the following which would find and remove all occurrences of non-standard HTML tags using brackets []:

$text =~ s/[(\w)+](.*)[\/(\w)+]//g;

I’m hoping it is a simple exercise for someone who is better at regex than I am.

Thanks in advance for your help!

  • 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-20T00:11:14+00:00Added an answer on May 20, 2026 at 12:11 am

    You have to escape brackets because they have special meaning within regular expressions. Assuming that all attributes will be double-quoted with no double quotes inside them, the following should work.

    $text =~ s/\[\/?\w+(\s+\w+="[^"]*")*\s*\/?\s*\]//g;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Perl script that reads data from an Excel ( xls )
Here is what im trying to achieve. I have a perl script that looks
Here's the design I want to accomplish in Perl: A master script calls multiple
So, I have a bash script inside of which I'd like to have a
We have a servlet that needs certain variables like passwords, encryption salts, etc., not
I have a locked down kiosk terminal server. This terminal server has a perl
Alright, some of you might have noticed I've been working on this problem off
Backdrop: I have a file hierarchy of cvs files for multiple locations named by
I am new to Perl and am having trouble getting my scripts to run

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.