LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search string in Array

I have one 1D array in that array the elements are started like 04_02_26LS1004(format is yy_mm_ddserialnumber).I Dont know the array size. It may go more than 60000. I want to search the elements which are all matching for the first 8 characters(yy_mm_dd).I don't need to compare one element by one element using for loop.Please Suggest.

with regards

R.sathiyanarayanan
0 Kudos
Message 1 of 4
(2,936 Views)
i can't think of any other way than using a for loop and compare each element with the match pattern function. Since you are only comparing for a a part of a string the search array function won't work.

Chris
0 Kudos
Message 2 of 4
(2,936 Views)
You could sort the array, and then do a binary search for 04_02_26AA0000 (lowest possible according to ASCII table) and 04_02_26zz9999 (highest possible according to ASCII table) which should represent the lower and upper regions of the array sub-set containing these numbers.

You may need to do a bit of fiddling to test either side of the returned index values to make sure you have the correct index but this should work I reckon.

Regards

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 3 of 4
(2,936 Views)
Dear Shane,

Thanks for your valuable solutions.the solution given by you is working fine for me. Once again thanks

with regards

R.Sathiyanarayanan
0 Kudos
Message 4 of 4
(2,936 Views)