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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:08:56+00:00 2026-05-31T01:08:56+00:00

I am trying to get the date from the second cell in the table

  • 0

I am trying to get the “date” from the second cell in the table using regex,
but it is not matching, and I really can’t find out why.

my $str = '"    
    <td class="fieldLabel" height="18">Activation Date:</td>
    <td class="dataEntry" height="18">
        10/27/2011      
    </td>';

if ( $str =~ /Activation Date.*<td.*>(.*)</gm ) {
    print "matched: ".$1;
}else{
    print "mismatched!";
}
  • 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-31T01:08:58+00:00Added an answer on May 31, 2026 at 1:08 am

    Others have already pointed out that you want the /s option to make . match a newline so you can cross logical line boundaries with .*. You might also want the non-greedy .*?:

    use v5.10;
    
    my $html = <<'HTML';    
        <td class="fieldLabel" height="18">Activation Date:</td>
        <td class="dataEntry" height="18">
            10/27/2011      
        </td>
    HTML
    
    my $regex = qr|
        <td.*?>Activation \s+ Date:</td>
            \s*
        <td.*?class="dataEntry".*?>\s*
            (\S+)
        \s*</td>
        |xs;
        
    if ( $html =~ $regex ) {
        say "matched: $1";
        }
    else {
        say "mismatched!";
        }
    

    (2020 Update) But I’d use Mojo::DOM and CSS Selectors to get the date. The particular selector may depend on the complete HTML source, but the idea is the same:

    use v5.10;
    
    use Mojo::DOM;
    use Mojo::Util qw(trim);
    
    my $html = <<'HTML';
        <td class="fieldLabel" height="18">Activation Date:</td>
        <td class="dataEntry" height="18">
            10/27/2011
        </td>
    HTML
    
    my $dom = Mojo::DOM->new( $html );
    my $date = trim( $dom->at( 'td.dataEntry' )->all_text );
    
    say "Date is $date";
    

    If you have the complete table, it’s easier to use something that knows how to parse tables. Let a module such as There’s also HTML::TableParser handle all of the details:

    use v5.10;
    
    my $html = <<'HTML';
        <table>
        <tr>
        <td class="fieldLabel" height="18">Activation Date:</td>
        <td class="dataEntry" height="18">
            10/27/2011      
        </td>
        </tr>
        </table>
    HTML
    
    use HTML::TableParser;
      
    sub row {
        my( $tbl_id, $line_no, $data, $udata ) = @_;
        return unless $data->[0] eq 'Activation Date';
        say "Date is $data->[1]";
        }
     
    # create parser object
    my $p = HTML::TableParser->new( 
        { id => 1, row => \&row, } 
        { Decode => 1, Trim => 1, Chomp => 1, } 
        );
    $p->parse( $html );
    

    There’s also HTML::TableExtract:

    use v5.10;
    
    my $html = <<'HTML';
        <table>
        <tr>
        <td class="fieldLabel" height="18">Activation Date:</td>
        <td class="dataEntry" height="18">
            10/27/2011      
        </td>
        </tr>
        </table>
    HTML
    
    use HTML::TableExtract;
      
    my $p = HTML::TableExtract->new;
    $p->parse( $html );
    my $table_tree = $p->first_table_found;
    my $date = $table_tree->cell( 0, 1 );
    $date =~ s/\A\s+|\s+\z//g;
    say "Date is $date";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure how to describe what I'm trying to get from this question, but
i am trying to get date from my implementation of jquery date picker, add
I am trying to get the offset hours from UTC, given a summer date.
I'm trying to get the week range using Sunday as the start date, and
I'm trying to get NSDate from UIDatePicker , but it constantly returns me a
What I'm trying to do is quite simple in sql but I can't get
With ruby I'm trying to get format a date as such: 2009-10-01 Where I
For example, I am trying to get a min date, a max date, and
I am trying to get an array of a date plus the next 13
I am trying to get a attribute of a date picker to pull the

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.