LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to differentiate string containing characters vs. numbers?

Solved!
Go to solution
Right, a value of -1 means no match was found. Also, when you actually use this code you should directly connect VISA Read to the input string terminal of the 'Match Regular Expression' VI. The case switcher was just an easy way to show how it won't match on the wrong input and should not be included in actual code.

0 Kudos
Message 11 of 14
(763 Views)
Thanks.
0 Kudos
Message 12 of 14
(761 Views)

Hi, I hope you read this. I had a followup question. My read string is obviously something other than XX.XXXX or X.XXXX or even XX.XX or .XXXX, and I have these Search Regular Expression Boolean results wired to OR statements and tied that to a case structure that when TRUE, executes data logging and plotting. However, I have not received any data in the file, therefore there must be no number in my read string that fits these.

 

I put some indicators on my system to try and troubleshoot it and this is what I found, as one example:

 

Read Buffer (indicator directly after VISA Read): 1.4576

String Length (indicator directly after VISA Read): 10

Number of Bytes at Serial Port (after Number of Bytes at Port instrument settings vi and just before VISA Read, just as in example): 40.

 

Do these numbers seem reasonable? I need to figure out what exactly is in my Read string so that I know how to handle it. 

 

Thank you.

0 Kudos
Message 13 of 14
(748 Views)

I am not very familiar with talking to serial devices over VESA so whether or not those make sense I am not sure.  But what I can tell you is that if you want the match to be more flexible than XX.XXXX but be able to accomodate any arbitrary amount of numbers before and after the decimal then replace the regular expression you have now with this one --->   ^[0-9]+\.[0-9]+$

 

This new regular expression only requires at least one number before the decimal, an actual decimal, then at least one number after the decimal.  To be more explicit it will match X.YYYY, XXX.Y, but it will not match XX. or .YY

Message Edited by SiegeX on 11-25-2008 03:57 PM

0 Kudos
Message 14 of 14
(721 Views)