LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extracting numbers from a string

Hi ,
I am trying to find a way to extract all possible numbers from a string ;
for instance the string :

win2000 john 6.25e-3 12.34 wtk75a -17

would give me the results in an array of numbers:

2000.00000
0.00625
12.34000
75.00000
-17.00000

In LabVIEW6.1 there is an example doing so; only the problem lies in the
scientific notation number:
the example sees this part of the string as two seperate numbers: 6.25
and -4 .
Ofcourse I want this VI to see this part of the string as one single number
(0.00625) .

Anyone help will be appreciated ,

René Ramekers
The Netherlands



0 Kudos
Message 1 of 5
(3,990 Views)
Hi,
 
Try using Fract/exp string to number.
 
It will do the job
 
Regards
 
Dev
 
 
0 Kudos
Message 2 of 5
(3,980 Views)
Sorry Rene, the attached Vi was in LabVIEW 7.1.
 
So, u might not be able to open it.
 
Nevertheless you will find this function 'Fract/Exp String To Number'., in functions palette -> string-> string/number conversion on LabVIEW 6.1 too, so it should not be a problem.
 
Regards
 
Dev
 
0 Kudos
Message 3 of 5
(3,977 Views)

Devchander is right on the money but I think you will need a little bit more to parse the string.

This is very similiar to the Extract Numbers.vi example that ships. The only difference is the number format that is extracted for the string using Match Patten.  The Match Pattern returns -1 when it can't any more matches where as Fract/Exp String To Number returns 0 which could be ambiguous.

Might not be bomb proof but it worked for the string you posted.

cheers

David

Message Edited by David Crawford on 11-25-2005 06:37 AM

0 Kudos
Message 4 of 5
(3,971 Views)
Thanks devchander & David ,

it works perfectly ,

René

"David Crawford" <x@no.email> wrote in message
news:1132922439537-292746@exchange.ni.com...
> Devchander is right on the money but I think you will need a little bit
more to parse the string.
> This is very similiar to the Extract Numbers.vi example that ships. The
only difference is the number format that is&nbsp;extracted for the string
using Match Patten.&nbsp; The Match Pattern returns -1 when it can't any
more matches where as Fract/Exp String To Number returns 0 which could be
ambiguous.
> <img
src="http://forums.ni.com/attachments/ni/170/153677/1/Extract%20Numbers.jpg"
>
> Might not be bomb proof but it worked for the string you posted.
> cheers
> David
> Message Edited by David Crawford on 11-25-2005 06:37 AM
>
>
> Extract Numbers.jpg:
> http://forums.ni.com/attachments/ni/170/153677/1/Extract Numbers.jpg


0 Kudos
Message 5 of 5
(3,946 Views)