LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

filtering numbers from a string which differes in length

Hi guys,

              i am recieving a string from a piece of test equipment, the string contains letters and numbers, i just want the numbers but there position in the string isnt constant so i can't just spesify an offest and length.

 

Is there anything in the strings pallet that will extract the numbers ?

 

Here is an example of the string, showing the differences in length/position:

 

U=245.7E+0 I=0.100E+0 Watt=24.9E+0

U=245.5E+0 I=0.09E+0 Watt=25E+0

0 Kudos
Message 1 of 4
(2,399 Views)

If you know the exact pattern of your string, then you can use the Match Pattern primitive in teh Strings pallette. Some other functions are also quite useful in things like these.

 

have a go thro' the Strings pallette by keeping open the LV Help.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 2 of 4
(2,395 Views)

Hi Zac,

 

using ScanFromString with a format string of "U=%f I=%f Watt=%f" should do the trick...

 

Another option is to use SpreadsheetStringToArray with a space as delimiter to get a !D array of strings, then use a for loop to examine the single strings, search every string for "=" and get the part after the equal sign to convert it to a number using "fractional string to number". Or you use Partha's advice. Or... Smiley Wink 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 4
(2,379 Views)

A trick I often use is that passing non numerical characters to the string to number function will not hurt it. But the function will stop the conversion then it find a not recognizable character. As an example if you pass 0.100E+0 Watt=24.9E+0 string to number function it will return 0.100

 



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 4
(2,368 Views)