Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Generating a format template for a date

by davidrw (Prior)
on Oct 13, 2006 at 17:52 UTC ( [id://578188]=note: print w/replies, xml ) Need Help??


in reply to Re: Generating a format template for a date
in thread Generating a format template for a date

Extension of that idea, ditching the conditionals (implicitly burying them in the regex's):
while(<DATA>){ s/9999/YYYY/; # 4-char year first s/(?<=[^9])99(?=[^9])/MM/; # month is always in the middle s/(?<!YYYY.{4})99$/RR/; # 2-char year is always at end, and won +'t have a 4-char year already s/99/DD/; # the remaining 2-chars will be the day print; } __DATA__ 99/99/9999 99/99/99 99-99-9999 99-99-99 99:99:9999 99:99:99 99+99+9999 9999-99-99 9999:99:99 9999+99+99

Replies are listed 'Best First'.
Re^3: Generating a format template for a date
by jbert (Priest) on Oct 13, 2006 at 18:01 UTC
    Nice! Doing multiple subs on the same target is something which looks nicer using the implicit $_.

    I definitely need to read up on my extended regexps though, those look-ahead/behind assertions are gnarly, dude.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://578188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-16 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found