Extract numbers from text string

  • Follow


Hi folks,

Which is the best way to extract the numbers of the following string ?
HELP, /MEM, OUTPUT=str
PRINT, str

I'm trying something like:
str_out=STREGEX(str,'[0-9]*',/EXTRACT)

But nothing happens...
Any suggestions ? Thanks in advance,

nata





0
Reply nata 2/22/2011 7:08:32 PM

On 2/22/11 12:08 PM, nata wrote:
> Hi folks,
>
> Which is the best way to extract the numbers of the following string ?
> HELP, /MEM, OUTPUT=str
> PRINT, str
>
> I'm trying something like:
> str_out=STREGEX(str,'[0-9]*',/EXTRACT)
>
> But nothing happens...
> Any suggestions ? Thanks in advance,

Try using + instead of *:

IDL> print, str
heap memory used:    1302373, max:    1305378, gets:     1518, frees: 
    609
IDL> print, stregex(str, '[0-9]+', /extract)
1302373

Also, check out the MEMORY function.

Mike
-- 
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
0
Reply Michael 2/22/2011 7:46:42 PM


1 Replies
683 Views

(page loaded in 0.021 seconds)

Similiar Articles:













7/22/2012 5:02:36 PM


Reply: