Re: String to Number
- To: mathgroup at smc.vnet.net
- Subject: [mg27187] Re: String to Number
- From: vze295bp at verizon.net (David Reiss)
- Date: Fri, 9 Feb 2001 03:10:33 -0500 (EST)
- Organization: Scientific Arts
- References: <95tq99$m8c@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <95tq99$m8c at smc.vnet.net>, steffenz at server2.fo.FH-Koeln.DE wrote: > Hi > > I read a time from a file (this format 06:42) as a string. > > I would like to convert this string into to numbers (6 and 42). > > any suggestions? > > Thanks > > Steffen > > > Dipl.-Ing. Steffen Zozgornik > > Institut fur Licht- und Bautechnik > an der Fachhochschule Koeln > Gremberger Strasse 151 a > D - 51105 Koeln > > Tel.: +49 - 221 - 83 10 95 > Fax.: +49 - 221 - 83 55 13 Here is an example (the result is a list of the integers that you are looking for: In[1]:= TimeStringToIntegers[time_String]:= ToExpression[StringReplace["{"<>time<>"}",":"\[Rule]","]] In[2]:= TimeStringToIntegers["06:42"] Out[2]= {6,42} --David -- ) Scientific Arts: http://www.scientificarts.com ) Creative Services and Consultation for the Applied ) and Pure Sciences:: David Reiss: dreiss at !SPAMscientificarts.com ) [Remove the !SPAM to send email]