comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: extracting numbers
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: extracting numbers [message #48026] Thu, 23 March 2006 08:06
Norbert Hahn is currently offline  Norbert Hahn
Messages: 46
Registered: May 2003
Member
kl_tah@hotmail.com wrote:

> Hi, does anyone happen to know how to extract a sequence of numbers
> (including the sign) between two characters? for eg. I have
>
> AAAA = -23.445 /BBBBB
> and could like to extract the number between '=' and '/'
>
> cheers,

Depending on the positions in the string you may as well _read_ from a
string using the procedure reads:

buffer = "AAAA = -23.445 /BBBBB"
reads, buffer, z, format='(6x,f8.3)'
help, z
Z FLOAT = -23.4450

HTH
Norbert
Re: extracting numbers [message #48028 is a reply to message #48026] Thu, 23 March 2006 06:34 Go to previous message
Ken Mankoff is currently offline  Ken Mankoff
Messages: 158
Registered: February 2000
Senior Member
On Wed, 22 Mar 2006 kl_tah@hotmail.com wrote:
> Hi, does anyone happen to know how to extract a sequence of
> numbers (including the sign) between two characters? for eg. I
> have
>
> AAAA = -23.445 /BBBBB
> and could like to extract the number between '=' and '/'

IDL> print, stregex(string, "[0-9.\-]+", /subexpr, /extract)

works in the example above. More generally, removing all letters
would be this:

IDL> print, stregex(string, "[^a-zA-Z]+", /subexpr, /extract)

But you get the = and the trailing "/".

IDL> print, stregex(string, "[^\ \=a-zA-Z\/]+", /subexpr, /extract)

removes all spaces, equals, letters, and / characters...

-k.
Re: extracting numbers [message #48033 is a reply to message #48028] Wed, 22 March 2006 23:43 Go to previous message
Klaus Scipal is currently offline  Klaus Scipal
Messages: 45
Registered: November 1997
Member
Try following

tmp=strsplit(string,['=/'],/extract)
number=float(tmp[1])

cheers, Klaus



<kl_tah@hotmail.com> wrote in message
news:1143089539.095096.210300@u72g2000cwu.googlegroups.com.. .
> Hi, does anyone happen to know how to extract a sequence of numbers
> (including the sign) between two characters? for eg. I have
>
> AAAA = -23.445 /BBBBB
> and could like to extract the number between '=' and '/'
>
> cheers,
>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Envi display bands
Next Topic: Azimuth and Offset XYZ position correction

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:12:48 PDT 2025

Total time taken to generate the page: 0.00869 seconds