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?
Your regex looks fine. I tested with following one-liner it successfully captured both pieces from string.
The above one-liner in easier to read format:
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