LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match regular expression or pattern

Solved!
Go to solution

I am having big trouble with extracting measurement results from a string from serial port.
I get a report through serial connectio from some device. It looks like that:

                                    Plane 1 Angle 1 Plane 2 Angle 2 In
       
  	 RotorID      rpm            [g·mm]    [°]    [g·mm]    [°]  Tol
                          1964.7     0.145999  201.6 0.151779  346.5 Y
                          2014.5     0.156608  197.6 0.139722  340.9 Y
         ealon ok     2012.1     0.143454  199.8 0.150243  344.6 Y
         ealon nok    2023.3    0.430547  217.7 0.833347  313.3 Y
         DN-3259824_001  2135.9 0.305822  246.2 0.296502  305.2 Y
         DN-3259824_002  2051.4 0.324227  241.1 0.327651  299.0 Y
         DN-3259824_020  2045.9 0.139268  150.2 0.281890   21.6 Y

 I cannot separate data with spaces, because sometimes there is no "RotorID" so all data shifts to the left.
There are always 7 columns. Sometimes RotorID is empty sometimes it consists some chars and some numbers. I never know its length. Other data is always present and separated with space. 

Can you help me please.

 

0 Kudos
Message 1 of 5
(2,708 Views)

 

First use "Scan String For Tokens" then pull the float out of that.

 

This is from my library that I use to do exactly that. 

 

 

Omar
0 Kudos
Message 2 of 5
(2,686 Views)
Solution
Accepted by topic author gtu

 

 

If you wish to use a regular exprission.

Match regular expression or pattern.png

Omar
0 Kudos
Message 3 of 5
(2,669 Views)

Of Course,  There are easier ways to get those floats out of the serial device string.

 

The worst part is getting rid of all the extra spaces.  Use match pattern (regex option) to help out a bit:

!00.png


"Should be" isn't "Is" -Jay
Message 4 of 5
(2,643 Views)

Thank you so much for this. I am almost ashame of my previous attempts to parse this thing. You don't want to see my code. 🙂

Now I understand that regular expression thing. 

0 Kudos
Message 5 of 5
(2,596 Views)