in reply to dos file masks and regular expressions

DOS wildcards only know 2 meta symbols: * and ?.

In regex speak these would be written as .* and . respectively *)

All other characters have to be taken literally.


Update: depending on how close you want to come to the results of DOS's "dir" you need additional restrictions, like surrounding the expression with begin and end assertions as in: $re = '^help.*\.txt$';

Update: *) ? is exactly 1 character (not "one or none" as my previous .? described.
Thanks to riceWind for spotting my error.

Replies are listed 'Best First'.
Re^2: dos file masks and regular expressions
by rinceWind (Monsignor) on Jan 04, 2006 at 12:24 UTC

    I don't think you are correct about the ? wildcard. This is equivalent to plain '.' as zero occurrences of the character will not generate a match.

    For example ?ana*.txt will match banana.txt and panama.txt but not analyst.txt

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re^2: dos file masks and regular expressions
by fluffyvoidwarrior (Monk) on Jan 04, 2006 at 12:10 UTC
    Great !! . . Thanks, that works a treat. Didn't know to put the dot in front ie .*