07-14-2015 04:02 AM
Hi,
I need to compare 2 array A and B.
How can i find out the elements which have string partly the same as B? thanks!
for example.
A: aa123
aa122
aa121
dd121
kk121
B: aa
bb
cc
I need to find out aa123 .
07-14-2015 05:02 AM
see if that works for you, use match pattern in the strings pallet. I should serve your purpose
07-14-2015 06:23 AM
Your problem statement is not very clear - do I understand this correctly?
You want to take element 1 from A and compare it with element 1 from B
If the B-element is a substring of the A-element then output the element from A to your 'found' array.
Then compare element 2 from A with element 2 from B, then element 3 from each etc.
Stop when one array runs out.
If so, it is quite simple - feed both arrays into a for loop and auto-index on both. The loop will continue until one array is exhausted. Do your comparison inside the loop (use a Match Pattern node) and feed the output out through a conditional auto-indexing tunnel, with the condition taken from the match. The output array will contain only those items which matched.
07-14-2015 07:44 AM
@yeah wrote:
for example.
A: aa123
aa122
aa121
dd121
kk121
B: aa
bb
cc
I need to find out aa123 .
Do you need just the first match or all of the matches? Or does it have to correlate to the same location (ex: index 0 for both arrays)?
I'm picturing a FOR loop with Match Regular Express inside. The rest depends on your more explicit requirements.
07-14-2015 07:13 PM
Hi all,
sorry for missed two elements.
A: aa123
aa122
aa121
dd121
kk121
B: aa
bb
cc
I need to find out aa123 ,aa122 and aa121. which contain aa in array B. it will cost lost of time to use while loop to get the data, because array A is not fixed.
07-15-2015 05:08 AM
Hi nolsqn,
array B include over 300 elements, they start with different characters.
some of them have common letters, but some are absolutely different.
so i'm trying to find out the elements in array A which equal to one the elements in array B or
the elements in array A include the string in one of elements in array B.
07-15-2015 05:37 AM - edited 07-15-2015 05:38 AM
You need something like this
07-17-2015 01:19 AM - edited 07-17-2015 01:32 AM
Hi Crossrulz,
thanks for your help.
I modified the program you published here and manage to find out the elements.
it seems that you wired the output to the wrong connector? it should be match substring?
how can you get aa121? I use above program only get aa.
but for me, get aa is enough now.
it seems that only match substring + after substring can i get aa121....?
07-17-2015 06:55 AM
yeah wrote:
it seems that you wired the output to the wrong connector? it should be match substring?
how can you get aa121? I use above program only get aa.
but for me, get aa is enough now.
it seems that only match substring + after substring can i get aa121....?
My results say I didn't miswire anything. You can get the original string by following my example (use the conditional indexing tunnel with your original string).
07-17-2015 08:34 AM - edited 07-17-2015 08:35 AM
I think one of the problems that the OP had is, that his LabVIEW version is older than yours and do not have the Conditional tunnel option.
The OP interpreted that as an array build in the for loop.
To OP:
What version of LabVIEW are you using?