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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read only number from string and number

Solved!
Go to solution

I have "COM4" from my I/O.  how could to read number 4 only?

  Thank you

0 Kudos
Message 1 of 11
(17,142 Views)
There are many ways to do this. The string palette has several string search functions, such as Match Pattern. The LabVIEW Help for this function explains how to use it to find various things, such as just numbers. Hint: Look at the "A sequence of one or more digits" line.
0 Kudos
Message 2 of 11
(17,133 Views)
scan from string COM%d but there are many ways depending on the string assumptions (regular expressions, string parsing, match string) ....
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 11
(17,132 Views)

On the I/O I selected "COM4" but I only want to see only number 4 on indicator, please give me more help detail.

  Thanks

0 Kudos
Message 4 of 11
(17,122 Views)

falkpl wrote:
scan from string COM%d but there are many ways depending on the string assumptions (regular expressions, string parsing, match string) ....

I think a regex pattern of [1-9]+ should work in this case.

 

 


stevevantran wrote:

On the I/O I selected "COM4" but I only want to see only number 4 on indicator, please give me more help detail.

  Thanks


 

What kind of indicator?

 

0 Kudos
Message 5 of 11
(17,111 Views)
Solution
Accepted by topic author stevevantran
Like the attached image you can try it in "n" number of ways
Regards
Guru (CLA)
0 Kudos
Message 6 of 11
(17,091 Views)

How about using the resources you already have? Try this. Open LabVIEW>>Click Help>>Find Examples>>Select the search tab and type in "strings" and you should find "Extract numbers.vi"

 

Hope this helps

Now Using LabVIEW 2019SP1 and TestStand 2019
Message 7 of 11
(17,054 Views)

Hello, i might need your help regarding this matter.

I'm current taking a reading from Arduino from 2 accerolmeter to Labview. X=0.02 Y=-0.03 Z=0.99 A=0.33 B=0.42 C=0.84 (Example) 

But when i display them using Waveform Chart in labview, I need to use the array to count the position of the String from buffer which sometimes might be inaccurate due to the the value extracted.

I was told that i can use Search string from the beginning to allow the waveform to take in only the numeric. 

Are you able to assist me regarding this issue?

 

Below attached are the pictures..

Download All
0 Kudos
Message 8 of 11
(12,934 Views)

Example_VI.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

Message 9 of 11
(12,905 Views)

I realize a new question was asked, and jcarmody did a great job of answering it.  But I remember seeing a regular expression which pulls out a number from a string, and I've used it to turn a text file into a 2D array of numbers by splitting and processing each row.  It isn't as fast, but it is more robust because it works with any number in a string decimal or not, and the format of the string isn't needed for the processing.

 

http://forums.ni.com/t5/LabVIEW/regex-find-number-at-end-of-string/m-p/2511362#M764254

 

The regular expression is this.

 

(\d+(\.\d+)?)(?!.*\d+(\.\d+)?)

Message 10 of 11
(12,884 Views)