LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search 1D array partly the same as element

compare.jpg

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 .

 

 

 

 

0 Kudos
Message 1 of 15
(4,696 Views)

see if that works for you, use  match pattern in the strings pallet. I should serve your purpose

Regards
Message 2 of 15
(4,670 Views)

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.

Message 3 of 15
(4,632 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 15
(4,597 Views)

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.

0 Kudos
Message 5 of 15
(4,550 Views)

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.

0 Kudos
Message 6 of 15
(4,490 Views)

You need something like this


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 15
(4,475 Views)

Hi Crossrulz,

thanks for your help.

I modified the program you published here and manage to find out the elements.

123.jpg

 

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....?

0 Kudos
Message 8 of 15
(4,426 Views)

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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 15
(4,396 Views)

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?

 

Message 10 of 15
(4,365 Views)