ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

need help to split a string

Solved!
Go to solution

Hello All,

 

I am getting data like -4.11139E-06-2.20064E-013.15263E+01-1.18792E-05-3.72294E-025.50947E+024.60728E-05-1.00468E-01-1.07451E-08431-50-628-03.

I want to split this string to 

a = -4.11139E-06

b = -2.20064E-01

c =  3.15263E+01

d = -1.18792E-05

e = -3.72294E-02

f = 5.50947E+02

g = 4.60728E-05

h = -1.00468E-01

i = -1.07451E-08

Then ignore 431-50-628-03 from the output. 

 

Thank you very much in advance.

0 Kudos
Message 1 of 9
(3,775 Views)
Solution
Accepted by aro1

try this

 

split string.png

 

EDIT: remove the ? from the string.

 

Ben64

Message 2 of 9
(3,762 Views)

What are you getting that output from?  Maybe we can fix it before you get it as this string.

0 Kudos
Message 3 of 9
(3,742 Views)

Hi,

 

The good thing is that the numbers in the string all have the same format - they end in E+xy or E-xy.  So you can search for the E and then extract the next three values.  Then put the remaining string into a shift register of a While loop and iterate on it until there are no more E's.  Take a look at my example.

 

Steve

0 Kudos
Message 4 of 9
(3,717 Views)

All,

Thanks for the assistance. The proposed solutions from Ben64 and Steve_G are pricesly what I was looking for.

 

Ben64, just a note, the code works like I want it to with the "?". When the "?" is excluded, about 3 of the last elements are not picked

0 Kudos
Message 5 of 9
(3,676 Views)

 

Ben64, just a note, the code works like I want it to with the "?". When the "?" is excluded, about 3 of the last elements are not picked


I was talking about the ? in the string control on the front panel, not the ? in the string constant on the block diagram.

 

Ben64

0 Kudos
Message 6 of 9
(3,666 Views)

Oh, you did not attach a VI, or screenshot of the front panel, to your initial response. So I could not tell exactly what you had in the string control. I just used my values.

0 Kudos
Message 7 of 9
(3,660 Views)

The picture is a snippet, you can drag and drop it in a block diagram to recreate the VI (note that you may have to copy it on your desktop, or somewhere else, before moving it to a block diagram.

 

Ben64 

0 Kudos
Message 8 of 9
(3,652 Views)

Oh that's a useful and convenient feature. Thank you for pointing that out.

0 Kudos
Message 9 of 9
(3,637 Views)