LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String match failing to match string

Hello, I am trying to match a string from the serial output from a capacitive sensor, that would come in the form of the following:

 

1.505949 pF 23.47 deg.C
1.503296 pF 23.54 deg.C
1.500016 pF 23.48 deg.C
1.498763 pF 23.46 deg.C
1.497160 pF 23.50 deg.C

 

and so on, essentially a ones digit and six digits after the decimal point. I have the regular expression ([0-9]\.[0-9]{6}) I am trying to match with this, using code I have adapted from a temperature graph readout, however it continues to return -1 and not detect this regex in my output stream. Why is it that this is happening? Thank you.

0 Kudos
Message 1 of 8
(255 Views)

VI attached, it was dropped from my original post

0 Kudos
Message 2 of 8
(253 Views)

Match Pattern has limited regex ability.  Try using Match Regular Expression


using LV2017SP1
0 Kudos
Message 3 of 8
(248 Views)

I notice you are using "Bytes at Port" and that's usually not a good idea.

 

Watch this video: VIWeek 2020/Proper way to communicate over serial

 

Also try this for parsing your string

sacnCapture.PNG

EDIT: Fixed output1 display format so it was not rounding 

 

 

========================
=== Engineer Ambiguously ===
========================
Message 4 of 8
(216 Views)

The exact problem you have is that the {6} part looking for 6 matching characters in a row isn't supported by "Match pattern".  You could use "[0-9]\.[0-9]+" instead which searches for any number of digits after the decimal instead of always 6.

 

However just in general this seems too specific.  Are you 100% certain that you will never get back a reply with either a negative number or one that has 2 or more digits before the decimal?  It's much better to just scan for "a number" if you are going to convert it to a number later.  Basically doing what RTSLVU suggests.

 

If for some reason you do require the exact string and a numeric equivalent won't do, you either need to switch to a working pattern such as the example I gave, or the Match Regular Expression node as mentioned by a previous reply.

Message 5 of 8
(191 Views)

And you might want "%6iF..." to get six significant digits in scIentific notation just in case you see some microfarads instead of picofarads.


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 8
(147 Views)

@JÞB wrote:

And you might want "%6iF..." to get six significant digits in scIentific notation just in case you see some microfarads instead of picofarads.


That is not a valid conversion code.

 

If you want to include the "pico" part to read the value in whole F units, there cannot be any space between the number and the p. After eliminating the space in some other way,  you could use %pf as scan format to get ~1.5e-12 for the first number.

 

altenbach_0-1659807748265.png

 

0 Kudos
Message 7 of 8
(131 Views)

That's what I get for not having my lapheater booted up!

 

Obviously I would call Output 1 Farads and display in SI units e.g. 1.23456p or 21.0987u


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 8
(123 Views)