Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I am stuck on regular expressions. How can i match something that looks like;
C:\Documents\username\folder\filename ....

Replies are listed 'Best First'.
Re: pattern matching help
by gjb (Vicar) on Dec 16, 2002 at 13:55 UTC

    Have a look at File::Basename (in the standard distribution) before hacking away with regexs, problably it does something you want.

    Hope this helps, -gjb-

Re: pattern matching help
by fruiture (Curate) on Dec 16, 2002 at 14:00 UTC

    Do literate Programming: the solution is a function of the problem. Know the problem, know the solution.

    m{(?x) # i want to match [A-Z] # windos drive letter : #colon (?: #cluster \\ # backslash [^\\]+ # directory- or filename )+ #one or more }#end of pattern
    --
    http://fruiture.de
      thanks but this still doesn't pass the correct filename test on my cgi ;-(
        thanks but this still doesn't pass the correct filename test on my cgi ;-(
        Are you sure you don't have / instead of \?

        Copious use of debugging prints/warns would help identify whethre you have the match strng you expect and the rege you want

        Dingus


        Enter any 47-digit prime number to continue.