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: 

Parse letters from numbers

Hi, I have to parse the letters out of a string to just get the numbers. I have four cases (just using filler numbers for this), so I have-

Vbatt: 0.15V

Ichgin: 0.15A

Ichgin: 0.15A

Ibatt: 0.15A

and I want just 0.15 as an output string. How do I approach this for all different cases?

Thanks in advance

0 Kudos
Message 1 of 6
(3,467 Views)

For each line, parse the substring after ":"

0 Kudos
Message 2 of 6
(3,466 Views)

You can do it with a single Scan from String.  Read the Detailed Help for this function (drop the function on the Block Diagram, select it, and choose Help).

 

Bob Schor

0 Kudos
Message 3 of 6
(3,449 Views)

It wasn't clear if "I have four cases" means that each scan is one of the four or if we get the entire four-line string at once, differing only in the numerics between successive scans.

0 Kudos
Message 4 of 6
(3,447 Views)

The following regular expression would work:

([\d\.]+)

If you want to also extract the units, you could use the expression:

([\d\.]+)(\w)

 

Extract Numbers.png

0 Kudos
Message 5 of 6
(3,416 Views)

@Bob_Schor wrote:

You can do it with a single Scan from String. 


Here's probably what Bob had in mind:

 

Scanem.png

0 Kudos
Message 6 of 6
(3,412 Views)