08-08-2011 09:10 AM
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
08-08-2011 09:41 AM - edited 08-08-2011 09:41 AM
You could use the scan from string function:
08-08-2011 09:45 AM
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
08-08-2011 09:52 AM - edited 08-08-2011 09:53 AM
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:
08-08-2011 10:43 AM
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.
08-08-2011 10:49 AM
08-08-2011 10:59 AM
08-08-2011 11:07 AM
08-08-2011 11:57 AM
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.
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.
08-08-2011 03:01 PM
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. 🙂