
Laurent_R
Veteran
/ Moderator
Dec 14, 2012, 1:55 PM
Post #6 of 13
(4749 views)
|
Re: [stevieger] Parsing text and obtaining value
[In reply to]
|
Can't Post
|
|
Hi, since date and time are on the same line, you can capture both elements in one shot with something like this:
my ($date, $time) = ($1, $2) if m{Date: (\d?\d/\d\d/\d\d) .*Time: (\d?\d:\d\d:\d\d)}; Here, $1 captures the first expression in parentheses in the regex (i.e. the date), and $2 captures the second expression in parentheses. And $1 and $2 are then copied into the $date and $time variables. I changed the regex delimiters for {} instead of //, because that allows to use / characters (for the date) within the regex without making it too much more complicated. This might still be a little bit cryptic for you, but I hope you start to get a sense of these constructs.
|