LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to split a string into alfa-numerics and numerics ?

Thru I/O Assistant.vi I queried a GPIB frequency synthesizer and get a string " FRq99999.999999Hz " ( this is a micro Herz synthesizer and the query shows the correct value ).
The "9"'s are alfanumerics as well as the " FRq " and the " Hz ".

Thru a string indicator I can see this complete value on the front panel.

So far so good.
But now :

1.
How could I separate the numerics ( in string format ) out of this string and convert them into numerics in order to have them displayed in some numerics graph form ?

2.
How could I delete the " FRq " and the " Hz " out of the string, so that the " 9 " 's remain and could be converted into numerics ?
This result wil be the same as my question #1 but now ther
e will be no A/N remainder.

Thanks for any help.
0 Kudos
Message 1 of 5
(3,154 Views)
reteb wrote:
> Thru I/O Assistant.vi I queried a GPIB frequency synthesizer and get a
> string " FRq99999.999999Hz " ( this is a micro Herz synthesizer and
> the query shows the correct value ).
> The "9"'s are alfanumerics as well as the " FRq " and the " Hz ".
>
> 2.
> How could I delete the " FRq " and the " Hz " out of the string, so
> that the " 9 " 's remain and could be converted into numerics ?
> This result wil be the same as my question #1 but now there will be no
> A/N remainder.

Scan From String with a format string of "%.;%[^0-9]%f"

Explanation:

%.; : use point as decimal comma
%[0-9] : scan all characters not equal to 0 up to 9
%f : scan for floating point number using the decimal comma
indicated at the beginning.

Rolf Kal
bermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 5
(3,154 Views)
reteb wrote:
> 1.
> How could I separate the numerics ( in string format ) out of this
> string and convert them into numerics in order to have them displayed
> in some numerics graph form ?
>
You could use the function "scan from string" or (what I would prefer,
but that's just personal) the match-pattern wit a patern of [0-9\.]+

You will get the number in the "Matching Strin" output.

If the number allways starts a the same position, you could even just
use the "Fract / Exp String to number" function.

I hope, this helps a bit

Marco
Message 3 of 5
(3,154 Views)
I have attached a small VI which demonstrates two options given in this discussion thread (the scan from string and the Fract/Exp String To Number.

Hope this helps.

RikP
Application Engineering
National Instruments
Rik Prins, CLA, CLED
Software Development Engineer
Message 4 of 5
(3,154 Views)
Thank you guys !
I got the point and had some succes but still one problem.

At first, in the " Fract./Exp. String To Number " I got no fractional real value 99999,999999 just the integer 99999.
After some stumbling around I found that I could add a boolean constant (T) at the top side of the icon of this vi before I got the wanted fraction behind the comma.
Is this the right way or is there a more regular way ?

In the " Scan String " I also do miss the fraction ...,999999 and see only the integer.
Should something be added to the string formatting ?
And is the wanted part of the string ( 99999,999999 ), once outputted by this vi, automatically converted into a numeric or does it remain a string ?

I need numerics for graph displays.

Thanks ag
ain for any help.
0 Kudos
Message 5 of 5
(3,154 Views)