Extract Numbers from a String in LabVIEW

Updated Aug 14, 2018

Reported In

Software

  • LabVIEW

Issue Details

  • I am trying to parse an alphanumeric string and put all the numbers in an array. 
  • An instrument I am communicating with returns a number that I want to record but it also includes other characters and space that I do not want.  How can I just get the reading and not the extra characters and spaces?

Solution

The Match Regular Expression function can provide this functionality. Using regular expression characters, you can parse a string for specific combinations of characters and place the matching subsets in an array.

For example, in the snippet below, we are extracting numbers that contain a decial 


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

Additional Information

The built in LabVIEW example Extract Numbers with Match Pattern.VI gives another way to perform this using the Match Pattern function.

WAS THIS ARTICLE HELPFUL?

Not Helpful