[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding numbers in a string
From: |
E. Joshua Rigler |
Subject: |
Re: Finding numbers in a string |
Date: |
Wed, 20 Apr 2005 15:19:34 -0600 |
On Wed, 2005-04-20 at 14:20, Søren Hauberg wrote:
> Hi
> I have a string containing both numbers and letters, and I want to
> exctract the numbers and discard the letters. How do I do such a thing?
>
> /Søren
There's probably a better way, but try this at the command line in
Octave ('ismember' is an octave-forge function):
Octave:1> ['ab1234567890cd'](find(ismember(toascii('ab1234567890cd'),[48:57])) )
([48:57]) are the ascii integers that correspond to the strings
['0':'9'], in case you were wondering)
-EJR
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------