# Comparing string lists with partial match

Posted 1 month ago
343 Views
|
5 Replies
|
2 Total Likes
|
 I have two lists of file names, about 200-300 per list. (attached as text files below). The Intersection of the lists is smaller than expected, only around 50 or so; probably the result of appended version number updates.What I seek is a list of file names that are nearly identical, but have version number updates. I can describe this more accurately as file names that match up to the first non-alphabetical character in the filename. In this case the set of 'alphabetical' characters I wish to allow for initial part of string match includes both dash and underscore.How to approach parsing the names to address that notion? Attachments:
5 Replies
Sort By:
Posted 1 month ago
 Hi Jonathan,Something like this? extract[name_] := name // StringPosition[DigitCharacter | "."] // Part[#, 1, 1] & // StringTake[name, # - 2] & extract /@ modded 
Posted 1 month ago
 Hi Rohit,Your function did the trick, thanks! Here's how I used it to extract a list of files with different version numbers appended to the end
Posted 1 month ago
 Hi Jonathan,So now I am curious. Are all of those jar files being used by a single application? I did not recognize the names so I googled and they appear to be related to Minecraft. Can you share what you are trying to do? Totally understand if you cannot or don't want to.
 Rohit's solution works well, another alternative is Map[StringSplit[#, "." | DigitCharacter][[1]] &, modded] splits the strings at the first digit or "." and grabs the first result.Another option is pattern matching but that is a bit more complicated (but more powerful).Regards,Neil