extracting numbers from a string

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply rra1 (17) 11/25/2005 11:35:19 AM

See related articles to this posting


Hi,
 
Try using Fract/exp string to number.
 
It will do the job
 
Regards
 
Dev
 
 


frac_string.vi:
http://forums.ni.com/attachments/ni/170/153671/1/frac_string.vi
0
Reply x9561 (148613) 11/25/2005 12:10:34 PM

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
Reply x9561 (148613) 11/25/2005 12:10:35 PM

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.
<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
Reply x9561 (148613) 11/25/2005 12:40:39 PM

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
Reply rra1 (17) 11/28/2005 7:29:53 AM
comp.lang.labview 35383 articles. 13 followers. Post

4 Replies
437 Views

Similar Articles

[PageSpeed] 52


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

how to extract numbers out of a string containing numbers and ","
Hi there, I have a string containing numbers separated by comma ','. The string looks like "1,2,5,10,32". How can I get the output as a series of numbers out of it? My goal is to search for a series of numbers in such strings. I think I have to extract the numbers out first. Thank you very much, Ting On Friday, March 29, 2013 5:07:20 PM UTC-6, Ting wrote: > Hi there, > > > > I have a string containing numbers separated by comma ','. > > The string looks like "1,2,5,10,32". How can I get the > > output ...

Check if String.matches() AND (if yes) extract number from String?
Assume I have a String var and value like: String var = new String("foobar[345]"); Now I want to check if this string matches a certain pattern and if yes extract the number into a long var. The first part is easy: if var.matches("\\w*\[\\d+\]") { long l = ????; } ....but I have no idea on how to extract the number. How can this be achieved? Jochen On 11/21/11 7:04 AM, Jochen Brenzlinger wrote: > Assume I have a String var and value like: > > String var = new String("foobar[345]"); > > Now I want to check if this string matches a certa...

Extract a number from a string.
Hi All, Apologies if this is laughably simple, but it's been a long time since I've used Perl, and I seem to suffer from Homer Simpson's problem: every time I learn something new, it pushes old stuff out. I'm trying to extract a number from a line of text returned by a license-checking command. I open a pipe to the command, and read through each line that is returned. When I find the text "Maximum..." or "Current..." I want to extract and store the number in that line. I tried using something like this to start with: $lic_usage{$lic_type}{$max} = /\d+/ i...

Extract numbers from string
Say I have a phone number "(555) 555-5555" and I want to extract the numbers from it. What's the most succinct way to do this? E.g.: old_num = "(555) 111-5555" new_num = "5551115555" old_num = "555-666-7777" new_num = "5556667777" eggie5 schrieb: > Say I have a phone number "(555) 555-5555" and I want to extract the > numbers from it. What's the most succinct way to do this? E.g.: > > old_num = "(555) 111-5555" > new_num = "5551115555" > > old_num = "555-666-7777" > n...

Extracting number from string
I'm pulling SAS metadata from sashelp.vcolumn and massaging it into Excel spreadsheets that another application can understand. In the format column for numeric variables, I get a lot of BEST6. or BEST10. (plus 1., 3., ...) Is there a function or other simple approach so that I can extract just the numeric (e.g. BEST10. would give me 10?) I can write it with index and substring and if statements, but I was hoping for something a little more concise. Thanks ...

extract numbers from string
i have a data file with a header that has several lines, which i read with readf,1,firstline readf,1,secondline ..... firstline is a string that looks like xpixels = 1024 i am trying to convert this to a variable called nx which has the value 1024. is there a clean and easy way to do this? Thanks! Tobi wrote: > i have a data file with a header that has several lines, which i read > with > > readf,1,firstline > readf,1,secondline > .... > > firstline is a string that looks like > xpixels = 1024 > > i am trying to convert this to a variable called nx wh...

Extract numbers from string
Hi friends! I have a varchar field in my DB with numeric values separates by spaces. I need to extract the numbers to create an array. Example 1: 1820 1823 1825 --> need to be transform into 1820 1823 1825 Example 2: 1 5 21 31 <<> must be transform into 1 5 21 31 The difference between ex 1 and 2 is that there might be different length between numbers. Can anyone help me??? Thank you very much, Ezequiel On 14 Jan 2006 12:39:27 -0800, in <1137271167.529986.168260@g14g2000cwa.googlegroups.com> (comp.lang.php) "zek2005" <esapoznik@gmail.com> wrote: >...

extracting number from a string
This is probably a stupid question but i have a character string as follows: #1:P+02500.0842. I need to extract the 02500.0842 but in decimal format. If i simply convert the string from char to decimal all the values change because an ASCII 1 is 49 in decimal etc. I guess i could just subtract 48 from every number (after decimal conversion) but wondering if there is a better way. matt v wrote: > This is probably a stupid question but i have a character > string as follows: #1:P+02500.0842. I need to extract the > 02500.0842 but in decimal format. If i simply convert the > string...

how to extract numbers from string
I have a char type variable which contains A = 'Happy - Today 0303 ab5 cd50 efInf.txt'; I would like to extract the numbers after ab, cd, and ef automatically. I tried to use the regexp but it didn't work, so I think someone here might be able to help me. Thanks in advance J Hi, try this : A = 'Happy - Today 0303 ab5 cd50 efInf.txt'; [B,C,D]=strread(A,'Happy - Today 0303 ab%d cd%d ef%f.txt') E=sscanf(A,'Happy - Today 0303 ab%d cd%d ef%f.txt') J�r�me J�r�me wrote: > > > Hi, > > try this : > > A = 'Happy - Today 0303 ab5 cd50 ...

Extract numbers from a string
Hi, Let say I have a string, I would like to extract a number from it, however, I do not know how many digits does the number has. "12784" "123<a" "4<abc" "56<ab" Is there any efficient way to extract the number? Thanks, Alan Alan wrote: > > > Hi, > > Let say I have a string, I would like to extract a number from it, > however, I do not know how many digits does the number has. > > "12784" > "123<a" > "4<abc" > "56<ab" > > Is there any efficient way to ...

Extract numbers from string
Hi there, I have some char string I'd like to extract the numbers from. They are like X-225Y-295D1* X4855Y4785D1* X50800Y50800D1* The problem is more complicated since the strings aren't the same length. I need three variables: x, y and command. The command is the last number in the string. Any suggestions? Thanks :D Look at the help for regexp sscanf Ak6<k]eihkh*aca{dIppd#ldkak]lijq{{]u_kj]{{]{_^r]gp]U#e{{^qa For example: str1 = 'X-225Y-295D1*'; str2 = 'X4855Y4785D1*'; str3 = 'X50800Y50800D1*'; xyc1 = sscanf(str1,'%*c%f%*c%f%*c%f',[1 Inf...

Extracting numbers from string
Hello, I have a set of strings such as 'C:\Users\ELS221\Desktop\lonw_3170_0.bin' and I want to extract the number between the last '_' and the '.bin' for a large number of files (in this case answer would be 0) The string will vary in length and characters. The number will vary in digits (it will be a number between 0 and 3000) but will always be in the same position in the string. As another example, I would want to extract 2309 from 'F:\Fieldsite2014\p3_28Apr14_3272\p3_28Apr14_3272_2309.bin'. I have been stuck on this for a while so any advice woul...

extract number from binary string
Hi I'm parsing a binary string, which encodes a number. I don't know the length of the string in advance: 1, 2, 3 or 4 bytes. The bytes of the string are in network order. How can I retrieve the number? I've written this sub, there must be a better way: sub parse_number { my $arg = shift; my $size = length($arg); my $value = 0; my $buf; for (my $i=($size-1);$i>=0;$i--){ $buf = unpack "C", (substr $arg, $i, 1); $value += $buf *...

Fw: extracting numbers from a string
--- On Mon, 12/28/09, William Krause <wkrause2003@YAHOO.COM> wrote: From: William Krause <wkrause2003@YAHOO.COM> Subject: extracting numbers from a string To: SAS-L@LISTSERV.UGA.EDU Cc: "William Krause" <wkrause2003@YAHOO.COM> Date: Monday, December 28, 2009, 1:45 PM I have a metadata table (tab1)that contains a field(infmt) which is the informat of a another field(response).=A0 The response field contains the response number and its assigned description. tab1 question=A0=A0=A0infmt response question1=A0 1.=A0 =A0 1=3D"test1"2=3D"...

extracting numbers from text string
Hello, I am new to Matlab. I have a very long text file with a repeating structure like: ----- Courant Number mean: 0 max: 0.136 Iteration No 1 DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 2.99476e-08, No Iterations 2 DILUPBiCG: Solving for Uy, Initial residual = 0, Final residual = 0, No Iterations 0 DICPCG: Solving for p, Initial residual = 1, Final residual = 9.41218e-08, No Iterations 737 time step continuity errors : sum local = 7.34978e-12, global = -2.46208e-14, cumulative = -2.46208e-14 DICPCG: Solving for p, Initial residual = 3.59809e-05, Final res...

Extract numbers from text string
Hi folks, Which is the best way to extract the numbers of the following string ? HELP, /MEM, OUTPUT=str PRINT, str I'm trying something like: str_out=STREGEX(str,'[0-9]*',/EXTRACT) But nothing happens... Any suggestions ? Thanks in advance, nata On 2/22/11 12:08 PM, nata wrote: > Hi folks, > > Which is the best way to extract the numbers of the following string ? > HELP, /MEM, OUTPUT=str > PRINT, str > > I'm trying something like: > str_out=STREGEX(str,'[0-9]*',/EXTRACT) > > But nothing happens... >...

Extract a number from a complicated string
Hi, I have to read some data from a file, and on each block it always appears the followng string; xyz.vs.1-81_1 . It appears a lot of time with different numbers like; xyz.vs.1-81_1 xyz.vs.1-1234_1 xyz.vs.1-56431_1 and so on My problem is that I need to extract from this string the number. For instance in xyz.vs.1-81_1 I have to extract the number 81, and in xyz.vs.1-1234_1 I need to get the number 1234. What is the easiest way of doing this ? Thanks Horacius ReX a �crit : > Hi, > > I have to read some data from a file, and on each block it always > appears the followng st...

Extract Number From Text String
Hello, Does xHarbour have a function to extract Number from a text string? Regards Otto Dear Otto Haldi: On Monday, September 17, 2012 11:48:58 AM UTC-7, Otto Haldi wrote: .... > Does xHarbour have a function to extract > Number from a text string? http://www.ousob.com/ng/53guide/nga7e04.php val() David A. Smith On Mon, 17 Sep 2012 12:05:13 -0700 (PDT), dlzc <dlzc1@cox.net> wrote: Hello David, Thanks for your help. Yes, I know the function val() I mean for that kind of string : "abc-2344-2323". Regards Otto >Dear Otto Haldi: >...

compare and extract number from string
Hi, all &nbsp; If I want to compare a requirement number and extract a number form a continuous data, . for example, &nbsp; the string like this ( ******** 123 ****** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *********456 ****** &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&am...

Extract Number from a String File
Hello, I am having difficult extracting number from various string files.. string is something like the following: E.250anneal_Wi.1000.Le.30_04_Vd0.01_IdVg.txt And I want to extract data as follows: 1. Anything before Wi. (ie in this case E.250anneal) 2. The integer after Wi. (in this case 1000) 3. The integer after Le. (in this case 30) 4. The integer after the length value but before Vd (04) 5. The integer after Vd (0.01) I've tried using textscan to just figure out the values after Wi and Le but it doesn't seem to be working very well and just give me empty values ...

Re: extracting numbers from a string
I'd use some sort of regexp to parse RESPONSE. Too busy at work right now to craft the full one, and I'm not entirely sure how best to recursively parse it; but that's the easiest general approach, i'd think. Otherwise, perhaps SCAN the " " and use that to determine where the positions start/end? Replace every second " with "| or something to get a nice delimited string, and then proceed from there using a normal SCAN routine. -Joe On Mon, Dec 28, 2009 at 1:45 PM, William Krause <wkrause2003@yahoo.com>wrote: > I have a metadata ta...

Re: Extracting number from string
Use COMPRESS. num=compress(Str,,'ap') should remove letters and dots. -Joe On Tue, Sep 29, 2009 at 10:16 AM, Ken Barz <zrab123@comcast.net> wrote: > I'm pulling SAS metadata from sashelp.vcolumn and massaging it into Excel > spreadsheets that another application can understand. In the format column > for numeric variables, I get a lot of BEST6. or BEST10. (plus 1., 3., ...) > Is there a function or other simple approach so that I can extract just the > numeric (e.g. BEST10. would give me 10?) I can write it with index and > substring and if statements, bu...