LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

in "Match First String", 13 is matched with 1

I find a weird thing with "Match First String".
with a string array holding '1', '3', '13', the index for string '13' is 0. is there any revised version of String match available?  thanks.
0 Kudos
Message 1 of 7
(3,604 Views)
Probably you should read the help for "Match First String". It compares the beginning of string with each string in the array. Even empty strings in the array are returned as matches.
If you want to look for perfect matches, use the "Search 1D Array" function from the array palette.

0 Kudos
Message 2 of 7
(3,598 Views)

I cannot see the problem.

Please attach a small program containing useful defaults in all controls.

Let us know

  1. What you get as result
  2. What you expect as result.

I believe that if you have an arrray containing the strings [1,3,13] and a string of "13", 0 is the correct index result. Is that what you are doing?

(Element 0 of the array is the first element that matches the beginning of "13" (the "1"!), so the output string="3" and index=0.)

0 Kudos
Message 3 of 7
(3,597 Views)
Thanks everyone.
I know the index of 0 for '13' is correct for this function. But my expected is 2 (the exact match of '13').
Anyway, I put the string array into a while loop and end the loop with the exact match of the strings. 
0 Kudos
Message 4 of 7
(3,590 Views)
As stated before, if you're looking for exact matches, why don't you use "Search 1D Array"?
0 Kudos
Message 5 of 7
(3,589 Views)

This is a confusing function the first time you look at it. I came across it when I wanted to do the opposite and find the first element of an array whose beginning matched some string input. For example, if my array was [123,456,789] and my string was 12, I wanted 123 to be returned. Easy enough to code, but i was looking for a function that did it. I digress.

As has been said, Match First String is doing exactly what it's supposed to do.

0 Kudos
Message 6 of 7
(3,585 Views)
Thanks. search 1d array did the work.
0 Kudos
Message 7 of 7
(3,580 Views)