Plankton has asked for the wisdom of the Perl Monks concerning the following question:
And here's the output I get ...#!/usr/bin/perl -w while(<DATA>) { chomp; if ( /^-{0,}P{1,1}T{0,}\d{1,}[Y|M|D|H|S]{1,1}/ ) { print "$_ matches\n"; } else { print "$_ NO match\n"; } } __DATA__ PnYnMnDTnHnMnS -P1Y P3Y3M3DT3H3M3S P3M3Y3DT3H3M3S P334Y3DT3H3M3S PT2H 5T PT P5M6DT P5M6DT9 P600T6S
As you can see my regex is quite cutting it. P5M6DT, P3M3Y3DT3H3M3S, and P5M6DT9 should not match. And tiny brain is fried!PnYnMnDTnHnMnS NO match -P1Y matches P3Y3M3DT3H3M3S matches P3M3Y3DT3H3M3S matches P334Y3DT3H3M3S matches PT2H matches 5T NO match PT NO match P5M6DT matches P5M6DT9 matches P600T6S NO match
| Plankton: 1% Evil, 99% Hot Gas. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: duration regex
by Abigail-II (Bishop) on Oct 07, 2003 at 08:29 UTC | |
|
Re: duration regex
by Enlil (Parson) on Oct 07, 2003 at 07:18 UTC | |
|
Re: duration regex
by cLive ;-) (Prior) on Oct 07, 2003 at 06:02 UTC | |
|
Re: duration regex
by Roger (Parson) on Oct 07, 2003 at 06:59 UTC | |
|
Re: duration regex
by BrowserUk (Patriarch) on Oct 07, 2003 at 08:47 UTC |