The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD2017 - Friday Mind Bender - Parse that string

Active Participant

What are the contents of Parsed Array Out following execution of the VI?

 

Friday Mind Bender.png

 

Work through the VI yourself or expand the Spoiler tag to see the possible answers.

 

Spoiler
Friday Mind Bender Answers.png 

Combined.png

Comments
Member

b

timmy
Member

b

Member

B

Member

B is the ans.....!!

Member

B

Member

B)

A few things to watch out for here:

1. The 'delimiter' constant label is a trap. It's a search string and it works different from the 'delimiter' inputs of e.g. the spreadsheet string functions.

2. Search/Split String has as outputs the substring before the match (AB), and the substring MATCH+substring after match (C), and the offset of the match. This is different from the Match Pattern/Regular Expression functions which split the string into substrings before match, match and after match and output the offset AFTER match.

3. Notice the empty elements at the end of the Arrays.

Knight of NI

B


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

The answer is B.

However, I have a question about the results of "offset of match" output when I run the vi myself.

 

In the first run, input string = "Steve,Likes,LabVIEW"; offset input = 0; offset of match = 5, which indicates the position of the first comma and makes sense.

 

In the second run, input string = ",Likes,LabVIEW"; offset input = 6; offset of match = 7 which I couldn't understand because it looks like the position index of the second comma should be still 6

 

Does anybody have any clue on that?

Knight of NI

Ellie90, I am getting {5, 6, -1, -1} when I run it.  You probably have a space in your initial input string constant after the commas or some extra character of some sort.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

crossrulz, I double checked and yes you are right. I have a space after each comma by habit. Silly mistake. Thank you for answering it!

Member

B

Member

 

Hello everyone!

 

Nice exercise SercoSteveB...

After reading Search/Split String help context I could understand the output result of the exercise.

So, the correct answer is letter B...

Thanks and see you soon!

Smiley Very Happy

Tarciso Junior
+55 (11) 996-282-103
Skype: Tarciso.junior2
Email: Tsjabrantes@gmail.com
http://br.linkedin.com/pub/tarciso-junior/23/a83/463
Member

Steve,Likes,LabVIEW in that answer is B. But offset past match is initially 5 & finally -1 logically I can understand my doubt is middle values 6,-1. I can't understand logically.  Can anyone tell the logic behind this 5,6,-1,-1?

Knight of NI

Look at what is in the string shift register after each iteration.  The Search/Split String is removing everything before the found comma.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
NI Employee

b)

Member

Thanks for clarifying my doubt... But I got an confusion in this string slow,and,steady,wins,the,race I got an offset of match values are 4,4,6,9,-1,-1 in that I unwired the iteration terminal & +1 increment. I connected offset of match value as it is & connected to shift register. My confusion is why I am getting 9 instead of 5 & 4 (,wins,the,) help me, find out the logic behind 9.search or split string (1).jpg

 

Knight of NI

The offset input tells the Search/Split/String where to start looking for the search string.  So in your example, you have ",wins,the,race" with an offset of 6 (passed from the previous iteration).  Therefore, the comma will be searched for starting at the 't' in "the".  The next comma after that is in position 9.


There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Member

Thank you so much...cleared all my doubts...Smiley Happy


 

Member

B

Happy to Wire
Member

la risposta é B

 

Active Participant

Answer: B.  Nice one all. 

 

LabVIEW 2017 Help for the Search/Split String function.

Combined.png