develooper Front page | perl.perl6.users | Postings from October 2018

A regex that tickles me

From:
ToddAndMargo
Date:
October 3, 2018 01:45
Subject:
A regex that tickles me
Message ID:
87ac71b6-dbef-ba2b-a8ad-3d5e489f17d2@zoho.com
Hi All,

This regex just tickles me.  I am converting a date
(2018-09-15) I harvest from a web page into a
revision number (2018.09.15).  The particular web site
only dates for their releases, so, no problem, I am using
Perl 6


#!/usr/bin/env perl6

my Str $x = "2018-09-15";
$x ~~ s/ (<:N>**4) "-" (<:N>**2) "-" (<:N>**2) /$0.$1.$2/;
say $x;

2018.09.15

I am starting to just peal off regex's.  They are also starting
to become fun.  (Uh oh, did I just admit to brain damage?)

:-)

-T



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About