From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Determining Whether a String Contains Only Numbers using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

1. Overview:

This example checks if the string is just a number

 

2. Description: 

This example will get an string and perform several analysis over to determine if it is a number or if it contains any character. If it is a number, the LED in the front panel will be set to true.

 

3. Requirements

  • LabVIEW 2012 (or compatible)

4. Steps to Implement or Execute Code

  1. Insert a string 
  2. Run "Check If String is Number LabVIEW 2012 NI Verified.vi"
  3. If the string is a number the LED will be set to true

5. Additional Information or References 

 

 VI Snippet

Snippet.png

**This document has been updated to meet the current required format for the NI Code Exchange.** 

 

 

Jared S.
Applications Engineering
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
jcarmody
Trusted Enthusiast
Trusted Enthusiast
on

Or, you could do this:

or_this.png

Or:

find floats too.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

RL123
Member
Member
on

add a plus sign or a minus sign:

(^[+-]+[\d]+\.?[\d]*$)|(^[\d]+\.?[\d]*$)|(^\.[\d]+$)

altenbach
Knight of NI Knight of NI
Knight of NI
on

I probably would use lexical class for the original problem.

 

altenbach_0-1648920992063.png