in reply to Re^2: Parsing Regex
in thread Parsing Regex
Seems such a trivial thing, don't you agree?
Let's give it another shot.
while (<DATA>) { # lol, comments in __DATA__ :) next if m/^#/; #m!! to allow for better-readable slashes inside the regex #/x modifier to make the regex even better readable ($date, $address) = $_ =~ m! .*? (\d+ / \d+ / \d+)? \s* (.+) !x; print "date:<$date>\naddress:<$address>\n\n"; } __DATA__ # a line without a date A very good looking address # a line with a date 15/5/85 That's my actual birth day!
Output:
date:<> address:<A very good looking address> date:<15/5/85> address:<That's my actual birth day!>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Parsing Regex
by deMize (Monk) on Sep 23, 2009 at 13:48 UTC | |
by deMize (Monk) on Sep 23, 2009 at 14:56 UTC | |
|
Re^4: Parsing Regex
by deMize (Monk) on Sep 23, 2009 at 05:34 UTC |