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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:32:04+00:00 2026-06-09T21:32:04+00:00

I have documents with HTML Tables. Some of the cells have only numbers. Other

  • 0

I have documents with HTML Tables. Some of the cells have only numbers. Other cells have numbers and words.

Is there any way to keep just the contents of the cells that have words and not keep the contents of cells with only numbers?

Is there a module that anyone is aware of that I could use to do this? Alternatively, is there anyway I could use a regular expression?

<table>
<tr>
<td>WORDS WORDS WORDS WORDS WORDS WORDS 123</td>
<td> 789</td>
</tr>
<tr>
<td> 123 </td>
<td>WORDS WORDS</td>
</tr>
</table> 

I am still pretty new to perl, so please excuse my question if it is very simple. Also, I have already been warned about the potential problems of parsing HTML text using a regular expression.

Thanks so much!

Eventually, I’ll use a module to kill all of the HTML code, by the way.

  • 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-09T21:32:05+00:00Added an answer on June 9, 2026 at 9:32 pm

    As you already stated, HTML should not be parsed with regular expressions. A specialised parsing module like HTML::Parser can be of help:

    #!/usr/bin/env perl
    
    use strict;
    use warnings;
    
    use HTML::Parser;
    
    my $p = HTML::Parser->new( 'text_h' => [ \&text_handler, 'dtext' ] );
    $p->parse_file(\*DATA);
    
    sub text_handler {
        my $text = shift;
        $text =~ s/^\s*|\s*$//g;         # Trim leading and trailing whitespaces
        return if !$text || $text =~ /^[\d\s]+$/;
    
        print "$text\n";
    }
    
    __DATA__
    <table>
    <tr>
    <td>WORDS WORDS WORDS WORDS WORDS WORDS 123</td>
    <td> 789 558 </td>
    </tr>
    <tr>
    <td> 123 </td>
    <td>WORDS WORDS</td>
    </tr>
    </table>
    

    Output:

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

Sidebar

Related Questions

I have a table with a bunch of cells. (No way! Amazing! :P) Some
I have a curious little bug in some HTML that only show up in
I have a page with some tables like this: <html> <ol> <li>entry1</li> <li>entry2</li> <li>entry3</li>
I have an HTML document where I have two different tables. One is class
I have 2 html documents inside my google apps script project (showHtml1, showHtml2). I
I have a console application which is parsing HTML documents via the WebRequest method
What is the reason for the granularity of images in HTML documents? I have
I'm just starting out with JQuery in a Drupal environment. I have some thumbnails,
Hi I have HTML table of documents, each row is a document has link
I have a html table similar to this: <table> <tr> <td>1</td> <td>Some text...</td> </tr>

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.