LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to distinguish numerics and characters in a string

Solved!
Go to solution

I'm looking for a simple way to do it or any built-in subVIs that can do this.

I have 3 strings "1234c", "ab3dc". "xya", I want to identify the ones that have numbers and retrieve all numbers. So one important step is to distinguish the numeric characters and non-numeric characters. How can I do it in Labview with built-in subVIs?

 

ThanksSmiley Happy

Arnold
0 Kudos
Message 1 of 7
(3,603 Views)

Hi mugger,

Use match Pattern from function palette>>String functions.

Read help file you will come to know about its function.

You can find A sequence of one or more digits and characters using this function.

 

Best Of LuckSmiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 2 of 7
(3,595 Views)
Solution
Accepted by topic author mugger

[0-9] looks for a number, "+" makes the search look for 1 or more of them (it's "greedy", so it'll get as many as there are.)  I added one more string to your list to show that Match Pattern will match only the first instance of a number.  If there's a chance that you'll have data like the last element you'll need to run it in a loop.  Decimal String to Number can also work if a digit is the first character it finds.

 

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 3 of 7
(3,566 Views)

How are the strings created? do you have the control to structure these?

0 Kudos
Message 4 of 7
(3,534 Views)

Thanks buddy, that really helpes alot!

Another question is I have a XY graph with multiple cursor on it. I'd like to drag cursors, one at a time. So my question is how can I let labview know which one I drag? any idea?

Arnold
0 Kudos
Message 5 of 7
(3,482 Views)

@mugger wrote:

Another question is I have a XY graph with multiple cursor on it. I'd like to drag cursors, one at a time. So my question is how can I let labview know which one I drag? any idea?


You should start another thread for this question.

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

0 Kudos
Message 6 of 7
(3,456 Views)

For single characters there is the "lexical class" node under comparison. I'm just mentioning it since it's not a very well known node.

0 Kudos
Message 7 of 7
(3,436 Views)