Re: regex question matching dates



John W. Krahn wrote:
Richard Lee wrote:
given then ARGV[0] is 2008052803, why woulnd't below regex match them??

2008052803 is a ten digit number.


} elsif ( $ARGV[0] =~ m/\b2008[01][1-31]([01][0-9]|2[0-3])\b/ ) {

Your pattern matches eight digits with a \b word boundary at each end so it will never match a ten digit number. Also the character class [1-31] could be more simply written as [1-3] (repeated characters are ignored.)


@array = qx#ls -tr $directory/$ARGV[0]*#;

Why not do that directly in perl:

@array = map $_->[0], sort { $a->[1] <=> $b->[1] } map [ $_, -M ], glob "$directory/$ARGV[0]*";


#2008052803


John
hey thanks!

this works fine now

} elsif ( $ARGV[0] =~ m/\b2008(0[1-9]|1[12])(0[1-9]|1[0-9]|2[0-9]|3[01])([01][0-9]|2[0-3])\b/ ) {
@array = qx#ls -tr $directory/$ARGV[0]*#;
#2008052803
} else {

I will try that direct perl solution as well!!
.



Relevant Pages

  • Re: Larger field than thought?
    ... I need to generate automated account numbers for a new ... As I see it, I can change the above routine to check for 4 digits, instead ... Some form of loop to go through all parts in the database ... John W. Vinson/MVP ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Variable type to hold largest whole number
    ... John wrote: ... reach the limit of what a variable type can hold and lets say add 1, ... special classes (free or commercial to hold very large numbers ... If you want to go above 28 digits, you'll need to use a 3rd party class ...
    (microsoft.public.dotnet.general)
  • question about the loves algorithm
    ... I have a somewhat practical and maybe silly question about the 'loves' algorithm. ... For each character in the word 'loves', count the total number of occurences in both names 'John' and 'Jane'. ... Then start adding subsequent digits until a 2 digit number is obtained, ...
    (sci.math)
  • Re: question about the loves algorithm
    ... I have a somewhat practical and maybe silly question about the 'loves' ... Let me explain first what the algorithm is. ... is John, and you like a girl named Jane. ... the number of digits seems to grow ...
    (sci.math)
  • Re: Formatted text field
    ... "John M" wrote in message ... > how is it possible to enable only numbers input in a jFormattedTextField? ... > I want that user can enter only digits. ... [This has some problems if the user types ...
    (comp.lang.java.programmer)