in reply to duration regex

I took a look at the link and believe that it should do what you ask (though I did make a couple assumptions like that the order must always be: PnYnMnDTnHnMnS and that what they mean by the number of seconds can include decimal digits to an arbitray precision means (?:\d*\.\d+|\d+(?:\.\d+)?)?S ).
use strict; use warnings; while (<DATA>) { chomp; my $hr = qr/\d+H/; my $min = qr/\d+M/; my $sec = qr/(?:\d*\.\d+|\d+(?:\.\d+)?)?S/; if ( m!^-?P(?:\d+Y)?(?:\d+M)?(?:\d+D)? (?:T (?:$hr(?:$min)?(?:$sec)? | $min(?:$sec)? | $sec ) )?$!x ) { print "$_ matches\n" } else { print "$_ does not match\n" } } __DATA__ PnYnMnDTnHnMnS -P1Y P3Y3M3DT3H3M3S P3M3Y3DT3H3M3S P334Y3DT3H3M3S PT2H 5T PT P5M6DT P5M6DT9 P600T6S __END__ PnYnMnDTnHnMnS does not match -P1Y matches P3Y3M3DT3H3M3S matches P3M3Y3DT3H3M3S does not match P334Y3DT3H3M3S matches PT2H matches 5T does not match PT does not match P5M6DT does not match P5M6DT9 does not match P600T6S does not match

-enlil