LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Regular Expression Format

Solved!
Go to solution

Hi Everybody,

 

I'm communicating with a scale, using the Continuous Serial Write and Read sub-vi.

It outputs a string with a format: 

 

ST, GS, + 0.00 g

 

I want to extract only the number and convert it into a double so I can graph the weight change over time.

The expressions I've been using with Match Regular Expression, have not been working.

 

I've tried

 

[0-9]+(\.[0-9]+)*

 

and 

 

d+(\.\d{2})?

 

Is there a better way to parcel this data?

 

 

0 Kudos
Message 1 of 4
(3,180 Views)

@smat123 wrote:

Hi Everybody,

 

I'm communicating with a scale, using the Continuous Serial Write and Read sub-vi.

It outputs a string with a format: 

 

ST, GS, + 0.00 g

 

I want to extract only the number and convert it into a double so I can graph the weight change over time.


 

I'm a big fan of Scan From String and Format Into String.  I gather that this is the output from a Balance.  Are the first two fields always 2 characters long?  That is, is the format of all of the strings <2 char>, <2 char>, <number> <unit>?

 

If so, I would pass the string into a "Scan from String" with format %2s, %2s, %f, %s.  If I don't need the first two fields, I can just not wire those outputs.  The third output will be the number, and the fourth will be the unit ("g") in your example, but if your balance autoscales, it might become "mg" or "kg").

 

You can also do some of this with Regular Expressions.  If you do, take advantage of the comma separators to skip past the first two fields.

 

Bob Schor

Message 2 of 4
(3,173 Views)
Solution
Accepted by topic author smat123

Hi smat,

 

it reminds me on the scales we use…

 

Try this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 4
(3,170 Views)

Damn, you others are too fast, but I'll post what I made all the same:

Scan From String.png

 

This reads the sign automatically and outputs the DBL as positive or negative.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 4 of 4
(3,161 Views)