Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to extract numbers from list elements with text?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70353] Re: [mg70335] How to extract numbers from list elements with text?
  • From: János <janos.lobb at yale.edu>
  • Date: Sat, 14 Oct 2006 03:06:43 -0400 (EDT)
  • References: <200610130530.BAA01154@smc.vnet.net>

On Oct 13, 2006, at 1:30 AM, Henning Heiberg-Andersen wrote:

> Hi,
>
> I have a list looking like this:
>
> { 1 Intensity 0.23523,  2 Intensity 0.00005,  3 Intensity 0.00004, ..}
>
> Is there a command which allows extraction of only the last number  
> appearing
> in each element
> of the list?. If not, how can I modify the list elements?
>
> Best regards,
>
> Henning Heiberg-Andersen
>

Assuming that your list elements are strings, here is a newbie approach:

In[1]:=
lst = {"1 Intensity 0.23523",
     "2 Intensity 0.00005",
     "3 Intensity 0.00004"};

In[2]:=
splst = StringSplit /@ lst
Out[2]=
{{"1", "Intensity",
    "0.23523"}, {"2",
    "Intensity", "0.00005"},
   {"3", "Intensity",
    "0.00004"}}

In[20]:=
ToExpression /@ splst[[All,3]]
Out[20]=
{0.23523, 0.00005, 0.00004}

János


----------------------------------------------
Trying to argue with a politician is like lifting up the head of a  
corpse.
(S. Lem: His Master Voice)


  • Prev by Date: Re: How to extract numbers from list elements with text?
  • Next by Date: Re: On order of options to Graphics
  • Previous by thread: How to extract numbers from list elements with text?
  • Next by thread: Re: How to extract numbers from list elements with text?