ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Splitting Strings by Character Number

Solved!
Go to solution

I'm trying to find a way to differentiate duplicates of files based off of their revision. Two files are the same but of different revision if they have the same file name, but a different suffix (always a capital letter) at the end.

 

For instance:

ABC123A.xxx

ABC123B.xxx

are both of the same file but of a different revision. 

ABC122A.xxx

ABC123B.xxx

are of different files and different revisions.

 

My problem is that I need to be able to determine if two files are the same but of different revisions. My idea for a solution was to strip the file extension, then split the remaining string into two, one being n-1 characters long, and the other being 1 character long. Is there a way to do this? All split string methods I've seen so far either require a complete match or a delimiter.

 

Thanks!

0 Kudos
Message 1 of 5
(5,605 Views)
Solution
Accepted by reesl

Use "String Subset"

 

string subset.png

Message 2 of 5
(5,589 Views)

To add to Prettypwnies anser:

GetFileExtension.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 5
(5,559 Views)

get_rev.PNG

 

Search and Replace string to find the location of your period (start of your file extension), decremented to get the rev digit, and fed into string subset of length 1 to pull out the character of interest.   

0 Kudos
Message 4 of 5
(5,555 Views)

If the string format is really that easy (and stays that easy) use Scan From String.

 

Use format specifier "%[A-Z]%d%[A-Z]" (characters in string, number, characters in string), and you'll get the string and number as output (extract to get 3 outputs). Optionally, use "%[A-Z]%d%[A-Z].%s" to also get the extension.

 

Once you have the results, you can either use a set (new in LV2019), variant attributes or an array to spot duplicates. Not sure if that's the showstopper, but we can help once you're there.

File Format.PNG

0 Kudos
Message 5 of 5
(5,535 Views)