f



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
rra1 (17)
11/25/2005 11:35:19 AM
comp.lang.labview 35205 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

4 Replies
1060 Views

Similar Articles

[PageSpeed] 15

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
x9561 (148464)
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
x9561 (148464)
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
x9561 (148464)
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
rra1 (17)
11/28/2005 7:29:53 AM
Reply:

Similar Artilces:

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: > 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??? $myArray = explode(" ", $myString) explode() splits up the string in its second argument at each ocurrence of the string in its first argument, and returns the results into an array. The manual http://fr.php.net/manual/en/function.explode.php gives good examples. Cheers -- Charlie zek2005 said the following on 14/01/2006 20:39: > > I have a varchar field in my DB with numeric ...

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 ...

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 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
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 a string from a string
hi. I do want to extract this string "abcdefg" from string "C:\dir1\dir2\abcdefg-12345gsd" Note : the length of the text string "abcdefg" may vary, but the last character is always "-". I need only the string "abcdefg" not "-12345gsd" thanks pjl Denmark Per Juul Larsen wrote: > hi. > > I do want to extract this string "abcdefg" from string > "C:\dir1\dir2\abcdefg-12345gsd" > > > Note : the length of the text string "abcdefg" may vary, but the last > character is always "-". > I need only the string "abcdefg" not "-12345gsd" > > thanks pjl Denmark Assuming you're using VB6... Dim s As String Dim n As Integer s = "C:\dir1\dir2\abcdefg-12345gsd" Debug.Print s n = InStrRev(s, "\") If n > 0 Then s = Mid$(s, n + 1) Debug.Print s End If n = InStr(s, "-") If n > 0 Then s = Left$(s, n - 1) End If Debug.Print s Easy, wasn't it? Jason Keats skrev: > Per Juul Larsen wrote: >> hi. >> >> I do want to extract this string "abcdefg" from string >> "C:\dir1\dir2\abcdefg-12345gsd" >> >> Note : the length of the text string "abcdefg" may vary, but the >> last character is always "-". >> I need only the string "abcdefg" not "-12345gsd" >> >...

Numbers to strings to numbers again
I think I an getting the hang of this language, but I ran into a puzzler. I have a large array of data objects initialized at onLoad() time in an HTML page. I send them in as numbers. I gather that things are strings unless specifically made otherwise. I do a search on the data, which is essentially a loop of string compares. That works fine. So I want to optimize a little bit, and do some basic numeric comparisons before I start the linear search. I did not use parseInt() or parseFloat(), I just used the str - 0 trick to force type conversion. However, something is not working. ...

numbers and strings into strings
Hello! Using [num,txt,raw] = xlsread() I'm importing several Excelsheets into Matlab. One of the coloumns contains products ID's which are either just numbers or numbers with additional text. Later on I want to do some parsing of the data and want therefore to scan for certain strings. The problem is that I can't get a vector of strings from these data. productcolumn = (raw(2:end-1,2)) Two entries as examples: [ 111] '111 XXX' productcolumn 39x1 2904 cell array >> char(productcolumn) ??? Error using ==> char Cell elements must be charact...

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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *********789*******) &nbsp; and I have requiremnts that I need to extract the number is nearest greater 450, so in the above example, I need to pick 456. &nbsp; How can I result it? &nbsp; thanks Just extract all numbers into an array, then find the element with the smallest absolute difference. See attached (LabVIEW 7.0). &nbsp; EDIT: Sorry, If by "Nearest greater" you mean the next higher number, you can use something like in my example II. (Also LabVIEW 7.0). &nbsp; &nbsp; If you don't recognize an node, just right-click on it and select help. :) &nbsp; You still need to add proper execption handling, e.g.: - What if no element is greater? - What...

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...

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 *...

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 ...

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: > >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 Monday, September 17, 2012 4:36:24 PM UTC-3, Otto Haldi wrote: > On Mon, 17 Sep 2012 12:05:13 -0700 (PDT), dlzc 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: > > > > > >On Monday, September 17, 2012 11:48:58 AM UTC-7, Otto Haldi wrote: > > >... > > >> Does xHarbour have a function to extract > > >> N...

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 #5
If you use PROC CONTENTS, and you need to get the w.d formats, check the FORMATL column. -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Data _null_; Sent: Tuesday, September 29, 2009 2:08 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Extracting number from string Instead if fiddling with the values from the dictionary which could cause a problem when if the format name has as embedded number. I would use PROC CONTENTS which will give the value of W directly. You could refine the suggestions by the others but using PROC CONTENTS requires no ...

Re: Extracting number from string #4
Instead if fiddling with the values from the dictionary which could cause a problem when if the format name has as embedded number. I would use PROC CONTENTS which will give the value of W directly. You could refine the suggestions by the others but using PROC CONTENTS requires no extra effort. proc format; value $s8ex(default=9) 'M'='Male' 'F'='Female'; run; proc contents data=sashelp.class fmtlen noprint out=fmtlen(keep=name format:); format name $quote10. sex $s8ex6.1 age height weight d12.3; run; proc print; run; On 9/29/09, Ken Barz <...

C string to LabView string
Hi I'd like to know if someone may tell me how to convert a C string to LabView String, because I need to use a function in C which is on a shared library .so, that function returns a "char *parameter", and I want to show that string to LabView through a string indicator of LabView. I found a CIN which receives a LStrHandle and convert to CStr string and it returns it as LStrHandle again. I modified that CIN in order to work as I wanted, but it didn't work, LabView crashed everytime I run this modified CIN, here is my code: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* &nbsp;* CIN source file&nbsp; &nbsp;*/ &nbsp; #include "extcode.h" &nbsp; /* stubs for advanced CIN functions */ &nbsp; UseDefaultCINInit UseDefaultCINDispose UseDefaultCINAbort UseDefaultCINLoad UseDefaultCINUnload UseDefaultCINSave &nbsp; CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod); &nbsp; CIN MgErr CINRun(CStr str_orig, LStrHandle str_mod) { &nbsp; &nbsp;&nbsp;&nbsp; int32 len; &nbsp;&nbsp;&nbsp; MgErr err = bogusError; /* bogusError is miscellaneous&nbsp;&nbsp;&nbsp;&nbsp; */ &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&...

extracting a leading floating point number out of a string
Hello, is there s simple way to get the leading floating point number out of a string with trailing characters like "123.32cm"? Many thanks Cornelius news.uni-bamberg.de wrote: > Hello, > > is there s simple way to get the leading floating point number out of a > string with trailing characters like "123.32cm"? > Many thanks > > Cornelius > > The following might not solve your problem in general, but how about starting from: | ?- append(F,[0'.|_],"123.32cm"), name(I,F). F = [49,50,51], I = 123 ? Cheers Bart Demoen ...

[haskell] number of numbers in a string
Hi all, I am busy learning Haskell, but I ran into the following problem: A sample string consist of the text "123abc456". Now I want to derive the number of numbers in this string, which is 2 in this example ("123" and "456") How can I program this is a simple manner, using the type definition NumberOfDeci::String->Int? Any help appreciated. Kind Regards, ActiveX ActiveX wrote: > Hi all, > > I am busy learning Haskell, but I ran into the following problem: > A sample string consist of the text "123abc456". Now I want to derive >...

Extract variable length numbers (tab delimitered) from a string?
As the topic says. I ahve a settings file where each line contains 2 numbers of varying length and I want to extract each number and assign to a variable, how would I go about that? Thomas Andersson wrote: > As the topic says. I ahve a settings file where each line contains 2 > numbers of varying length and I want to extract each number and > assign to a variable, how would I go about that? would this be a valid way to do it and would I need to chomp the second value? open my $settings, qq<, $settings or die qqCould not open $settings: $!\n; my $line = <$se...

Text string to Hex number string.
4-4-07 In my application I read a string in from a .txt file. The string consist of 8 groups of 2 digits representing hex codes. Like: 0112010208020211. I need to convert this in to hex numbers 01 12 01 02 08 02 02 11 so that I can attach a header and calculate a check sum. When I load 0112010208020211 into a string control set for hex display I get 3031 3132 3031 3032 3038 3032 3032 3131, which is ok because I can add my header and calculate the check sum in this form but how do I get it back to 01 12 01 02 08 02 02 11 form to send to the device under test? Thanks TeBlues &nbsp; &nbsp; &nbsp; sorry my computer freaked out and posted many times <img src="http://forums.ni.com/attachments/ni/170/239858/1/hex_fun.JPG"> Message Edited by James R on 04-04-2007 04:45 PM hex_fun.JPG: http://forums.ni.com/attachments/ni/170/239858/1/hex_fun.JPG ...

Web resources about - extracting numbers from a string - comp.lang.labview

Local Measure addresses the importance of extracting value from Big Data
There are many opportunities surrounding the Big Data space and if businesses milk the value from all the data they’ve got, it can change the ...

Dentist deregistered after extracting teeth and performing root canal work without patients’ consent
A DOWN-in-the-mouth dentist who extracted wisdom teeth and performed root canal work on patients without their consent has been deregistered ...

Extracting the digital
Alexa Moses tries to make sense of the Resfest digital film festival. - Sydney Morning Herald Online

Shy bidders' tactics make extracting bids almost as painful as dental work
Shy bidders' tactics make extracting bids almost as painful as dental work

Brookfield 'ruthless' in extracting infrastructure profits, says CBH
The nation's biggest grain exporter CBH Group has thrown its weight behind concerns by farmers over Brookfield's $8.9 billion proposed takeover ...

Companies extracting B.C. groundwater for free
Several groups are calling on the province to tighten groundwater laws as B.C. is the only jurisdiction in Canada that does not charge major ...

Extracting info: Why’s it so hard to get the goods on oil spills?
It can be tough to get a good sense of how safe Alberta’s oil industry is when you can’t access the information you need.

Krugman on extracting a price for intellectual dishonesty
Just a small point, but with it I want to make a larger one. ■ The small point is about Paul Krugman and his slow path to calling out his professional ...

When Oil Isn’t Worth Extracting
... the point at which energy resources become too costly to take out of the earth: We’ll never run out of any fossil fuel, in the sense of extracting ...

Revenge is ours: extracting energy from a cockroach
... inside it to use it as a mini-electricity generator. Now, I hate cockroaches as much as anyone, and there is a certain satisfaction in extracting ...

Resources last updated: 3/29/2016 5:18:52 PM