OK gentleman, I need your eyes and brainpower to help me find a better solution to this if there is one.
I have a phrase that I am extracting from SAP (via a view that was created) that will have words and numbers within this field. I've found that the numbers are in a decimal format.
Example: I weigh 250.45 pounds.
From this, I need to extract 250.45. I've done it using RegEx and with the Match Regular Expression Function but I am wondering if there is a faster, more efficient way. No other numbers would be present other than what you see in the example.
Solved! Go to Solution.
If the phrase is always the same, same number of characters, you can use the Fract/Exp String to Number VI and enter an offset.
There is an example in labview\examples\general\strings.llb (Extract Numbers VI) that will extract numbers from sentences. It uses Match Pattern. I think that will be your best bet.
Oh neat, for me the example was found here in 2017.
<LV Install>\examples\Strings\Extract Numbers with Match Pattern.vi
Earlier I was using regular expression of "\d+(\.\d+)?" but Match Pattern likely is more efficient for simple things.
EDIT: Oh and don't forget this has regional issues. This regular expression and the NI example both use the decimal point as the separate for the fractional part of a number and other countries use the comma. Code can be written which can be configured to use the system separator. I usually use a known math equation like the square root of 2, and convert that to a string then see what separator character is there.