LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to split the string from character position.

HI ALL,

 

I need to split the string like this.

 

example:

 

String = "HelloWorld"

 

mid("HelloWorld", 2, 5);

 

it should print   "ello"

 

menas mid is functiuon it will split "HelloWorld" from 2nd character to 5th character and prints "ello".

 

This one how to do in labview.

 


Regards

Punith

 

0 Kudos
Message 1 of 17
(7,181 Views)
The "string subset" function. It takes a length rather than an endpoint but will do what you want.
0 Kudos
Message 2 of 17
(7,173 Views)

I would go for two consecutive calls of string subset.
 MID.png



Remember Cunningham's Law
0 Kudos
Message 3 of 17
(7,171 Views)

String Subset is the function you are looking for.



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
0 Kudos
Message 4 of 17
(7,161 Views)
Peter, why do it twice? You can write both the start and length inputs, it's not either-or.
Message 5 of 17
(7,156 Views)

Smiley Very Happy

I guess this qualifies as an entry for Rube Goldberg code....

 

Dammit, any other day I would have noticed.



Remember Cunningham's Law
0 Kudos
Message 6 of 17
(7,146 Views)

Also note that the String Subset function uses an offset input, setting this input to 2 will make the 3rd character of the string the first one of the subset. If you want to output "ello" you need to set the offset to 1 (2-1) and the lenght input to 4 (5-(2-1)).

 

Ben64

0 Kudos
Message 7 of 17
(7,134 Views)

But if i want to split same string from 5th postion to two character , it is not working.

 

ex : mid("HelloWorld", 5,2);

 

it should print "oW".

 

How to do this.

 

Regards

Punith

0 Kudos
Message 8 of 17
(7,119 Views)
As Ben64 noted, the start input is an index (starts at 0 for the first character) so you need the inputs to be 4 and 2. You would have found this out faster by trying it out than by posting on the forum.
0 Kudos
Message 9 of 17
(7,105 Views)

I understand that in labview  char position of string starts from oth postition .

 

But my proble is if  i want interchange 5 and 2 its not working.

 

ex: mid("HelloWorld",5,2);

 

it should print "Wo" but it not working.

 

Regards

Punith

0 Kudos
Message 10 of 17
(7,066 Views)