Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find specif pattern in a string and return it?

Status
Not open for further replies.

webamoeba

Programmer
Sep 6, 2006
23
GB
Hi,

I have an array of file names, all of which follow a standard naming convention which includes a verison number.

The follwoing are all examples:

522.EC202012 PB v0.1a.doc
522.EC202012 PB v1.doc
522.EC202012 PB v0.1.doc
522.EC207896 FRS v1.1.xls
522.EC207896 FRS v2.xls
522.EC207896 PQ.xls

Some files have versions, some don't, some versions are precede by a .minorNumber and some by a .minorNumerAndALetter

I want create a new array that contains only the latest files. e.g. 522.EC207896 FRS v1.1.xls would not be in the new array becuase 522.EC207896 FRS v2.xls is a later versions.

How do I do this???

Thanks.
 
oops should also have said that documents without versions need to be copied into the new array as well.
 
Take a look at regular expressions, or "regex"'s. Google "Perl", "regex" and "tutorial". Very powerful stuff, and just the ticket for your task.
 
No worries, getting tehre anyways. my god i think im actually starting to understand Regular Expressions!
 
Because of the amount of variation in your version number scheme, it's going to be hard to parse reliably and work out which is newer. Can you use the timestamp from the file system instead?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
It's ok, I have sorted it now :) But thanks.

And sadly no I couldn't do it form the timestamp, because documents can be submitted late or early. But it would have been far nicer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top