Hi,
You were correct - the regex isn't matching. Here's a fixed-up and /x modified version:
#!/usr/bin/perl -w
use strict;
my $row = "Updated: Mar-11 23:05:50 PST";
if($row =~ /Updated\s*: #The String "Updated", followed b
+y zero or more spaces, then a colon
\s*\w+\s*-\s*\d{1,2}\s* #This matches " Mar-11 "
\d{1,2}:\d{1,2}:\d{1,2} #The time
\s*PST/x) { #The timezone - do you really nee
+d to be this specific?
print "Match\n";
} else {
print "No Match\n";
}
On the other hand: should you really be using a regex for this at all?
If it's a date, then
Date::Calc could do very well for you (check out parse_date).
I'd also recommend thinking about whether you really need to have " PST" in your regex at all - do all the "Updated" strings contain that timezone information?
hope this helps
davis
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist
Update: On re-reading your code, it appears that you're using parentheses to try and capture the whole string - these need to go
inside the regex delimeters.
And I won't even mention that you should be "use"ing "strict" and "warnings" ;-)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.