From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular exp

Hello,

 

i have a string buffer like this  \s\sNN.NN\s\s\s\sNN.NN\s\n

 

where NN.NN is value is measurement is OK  , could be open is not present

 

I would like to extract this two NN.NN  with regexp

 

an idea ?

 

 

Regards

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 1 of 19
(3,587 Views)

You could use the scan from string function:

 

 

0 Kudos
Message 2 of 19
(3,572 Views)

I know I should not assume that you would want the values to be converted to doubles.

 

Here's a link to the regular expressions thread, which may be useful:

 

http://forums.ni.com/t5/BreakPoint/Regular-Expressions-Board/td-p/1187799

0 Kudos
Message 3 of 19
(3,567 Views)

I have to run to a meeting, but here is a quick reg expression.  You'll need to fix it to get 2 significant digits:

 

 

Message 4 of 19
(3,561 Views)

This VERY SLIGHT modification gets you all the digits past the decimal point.  You can replace the asterisk with {n} to specify exactly how many digits you want.

 

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 5 of 19
(3,545 Views)

With one MRE (assumes only spaces separate the numbers):

 

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 6 of 19
(3,540 Views)

You can simplify the regex to "\S+", one or more character that is not a space if the output is always of the type \s\sNN.NN\s\s\s\sNN.NN\s\n.

 

Ben64

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

Alternate regex

 

select numbers.png

 

Ben64

 

 

Message 8 of 19
(3,530 Views)

In terms of flexibility and syntax error catching, I tend to prefer to use the digit class (\d).  Let me just remind the regexers about negative numbers.  Smiley Wink

 

If spaces are the enemy, then Ray.R chose the correct function but wandered into RG territory when he thought strings would be the desired output.  Just let Scan From String do its voodoo.

 

ScanFromStringEx.png

 

 

0 Kudos
Message 9 of 19
(3,516 Views)

We still don't know if the OP wants doubles or strings or why use regular expression at all.  I decided to go the regEx example because that was what was asked.. 

Thanks Jim for the simplified examples.  I enjoy learning more regEx.

 

I prefer the Scan from String as it does the trick..  and it can convert to the appropriate type in one shot.  🙂

0 Kudos
Message 10 of 19
(3,497 Views)