Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Pattern Matching in Arrays

by przemo (Scribe)
on May 12, 2009 at 22:44 UTC ( [id://763620]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Pattern Matching in Arrays
in thread Pattern Matching in Arrays

I liked the split method recommended above.

Unfortunately it doesn't work with multiple underscores.

If you want to stick with regexp, then try this:

if (/^(.*?)(?:_([^_]*))?\.pdf$/) { # do something with $1 and $2 }

Replies are listed 'Best First'.
Re^6: Pattern Matching in Arrays
by aj.kohler (Initiate) on May 13, 2009 at 18:28 UTC

    Let me try explaining the overall goal of the program:

    1. Read in directory of file names

      1. Most file names hava a Root number, Revision, Extension of pdf: 12345_-v1.pdf
      2. Most names have an underscore as the seperator between Root Number and Revision: 3873215a_-v1.pdf
      3. Many names have more than 1 underscore used as text seperators: 21586_rework_bore_tool_-v2.pdf
      4. Some names have no underscores in them: 4148-t-2.pdf
    2. I need to display only the latest revision of the file, so if the following exist in the directory:
      21586_rework_bore_tool_-v1.pdf
      21586_rework_bore_tool_-v2.pdf

      Only display 21586_rework_bore_tool_-v2.pdf
    3. I am unable to capture all of the combinations listed above...

    I appreciate all recommendations...

    AJ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://763620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2026-01-20 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (124 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.