09-21-2009 08:17 AM
I am trying to search a string for a number (integer or float) without knowing its index in the string and to extract it - whether in numeric or string format. e.g. "the number 52.63 appears in this string"; I want to extract/identify "52.63"
The functions I come across seem to expect the index to be known or the number to be at index 0. How can I achieve this?
Best regards.
Kenoss
Solved! Go to Solution.
09-21-2009 08:27 AM
Use the Search/Split Screen primitive. I'm sure there are plenty of examples in the Find and Example screen.
09-21-2009 08:46 AM
09-21-2009 08:56 AM
LabVIEW does not seem to have a function to pull any number from a string. We have an example of a way this can be done LV 8.6.1
Hope this helps
09-21-2009 09:03 AM
I forgot the warning for my the previous example. If the string contains multiple numbers in various locations in the string, all numbers will get concatenated into one output number.
IE: a string like- "Yes 12 months and 5 days is acceptable"- would have an output of 125
09-21-2009 09:06 AM
Thanks all for your variety of ideas which are very helpful!! I found using "[-]?[.]?[0-9]+[.]?[0-9]*" in regular expression input of Match Pattern function does the trick. Am investigating the individual meanings of this regular expression.
Many thanks.
09-21-2009 03:49 PM
kenoss wrote:Thanks all for your variety of ideas which are very helpful!! I found using "[-]?[.]?[0-9]+[.]?[0-9]*" in regular expression input of Match Pattern function does the trick. Am investigating the individual meanings of this regular expression.
Many thanks.
I was about to explain, but I figured it would be quicker to just post the 'LabVIEW Help' details.
09-21-2009 03:57 PM
If you are about to dive into the 'wonderfull world of Regular Expression' don't miss this (regular-expressions.info) site.
Ton
09-21-2009 04:07 PM
Check out [LabVIEW]\examples\general\strings.llb\Extract Numbers.vi. Seems to work well on the example string you give in your initial post. Is this what you were looking for?
09-22-2009 03:08 AM