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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:08:37+00:00 2026-05-30T12:08:37+00:00

I have this line in a CSV file: [2/16/2012] emailed…I honestly do not know

  • 0

I have this line in a CSV file:

[2/16/2012] emailed...I honestly do not know - I am an endpoint in sales – I would try contacting our corporate office. <STOP>

And this Perl regex:

m/\[(\d+\/\d+\/\d+)\]\s(.*)/

I would expect this regex to match the above string. When I take out the “-” characters in the string, the regex matches. Otherwise, it doesn’t. Why? I thought the “.” character means any character except the newline? What am I doing wrong?

  • 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-30T12:08:38+00:00Added an answer on May 30, 2026 at 12:08 pm

    Your regex looks fine. I tested with following one-liner it successfully captured both pieces from string.

    $ perl -e 'my $str = "[2/16/2012] emailed...I honestly do not know - I am an endpoint in sales – I would try contacting our corporate office. <STOP>"; print "full str: $str\n"; if ($str =~ m/\[(\d+\/\d+\/\d+)\]\s(.*)/) { print "matched\ndate: $1\nmsg: $2\n"; } else { print "did not match\n"; }'
    
    full str: [2/16/2012] emailed...I honestly do not know - I am an endpoint in sales – I would try contacting our corporate office. <STOP>
    matched
    date: 2/16/2012
    msg: emailed...I honestly do not know - I am an endpoint in sales – I would try contacting
    our corporate office. <STOP>
    

    The above one-liner in easier to read format:

    my $str = "[2/16/2012] emailed...I honestly do not know - I am an endpoint in sales – I would try contacting our corporate office. <STOP>"; 
    print "full str: $str\n"; 
    if ($str =~ m/\[(\d+\/\d+\/\d+)\]\s(.*)/) {
        print "matched\ndate: $1\nmsg: $2\n";
    } 
    else { 
        print "did not match\n"; 
    }
    

    Check to make sure there are no hidden metacharacters in your string. If on linux, you can run dos2unix to remove any Windows added carriage returns. If on windows, you can use notepad++ to show all characters. View->Show all characters

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

Sidebar

Related Questions

I have a csv file that looks like this: TEST 2012-05-01 00:00:00.203 ON 1
I have this code for parsing a CSV file. var query = from line
i have a csv file like this: i,0 <-- 1st line f,1,2,3 <-- 2nd
i have this huge csv file, it's 4GB, don't know how many rows but
I have this common issue of 'new line' in php-csv which is making me
I have this line: $(#clients-edit-wrapper).height($(window).height()-150); I would like to apply that height function to
I have this code to read a CVS file. It reads each line, devides
I have a CSV file with 6 millions rows. Each line is made up
How can I parse my CSV file without parsing first line ? This class
I have a bunch of data in a text file like this: 99150, 2012-05-18

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.