LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String help

Solved!
Go to solution
I am trying to count actual words in my string so that I can tell my for loop how many times to run. Is there a way to do this?
0 Kudos
Message 1 of 4
(2,670 Views)
Solution
Accepted by topic author Chod

We've already done that here:

http://forums.ni.com/ni/board/message?board.id=170&thread.id=491463

 

but if you don't like that method and you can guarantee 100% of the time that each word will be seperated by a space, you can:

1) clear whitespace around the string.

2) pass it through the search and replace string function and replace all spaces with something

 - the number of spaces +1 =number of words.

 

As I said in the other thread, this only works if you are dealing with WORDS.

 

If you are trying to convert the sentence "he has 10 cows" to pig latin, your function can handle it.

It can't handle Text speak like "R U coming round 2nite".

 

(Note it is the addition of a charcter at the start of a word which is causing a problem here. "It was bad (Very bad), so bad ..." is not handled at all well by your VI. I stand by my earlier code.)

 

James

 

Message Edited by James W on 04-16-2010 11:46 AM
CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
Message 2 of 4
(2,662 Views)
Sorry about that James! I got too hasty LOL
0 Kudos
Message 3 of 4
(2,632 Views)
I did check these type of strings with the second attempt VI that I posted and they were handled and converted, so if you haven't looked at at, please don't think it's a waste of your time.
CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 4 of 4
(2,628 Views)