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

Home » Public Forums » archive » Re: bug in stregex?
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: bug in stregex? [message #31526] Fri, 19 July 2002 18:07
William Daffer is currently offline  William Daffer
Messages: 34
Registered: February 1999
Member
Craig Markwardt <craigmnet@cow.physics.wisc.edu> writes:

> Vapuser <vapuser@catspaw.jpl.nasa.gov> writes:
>> I don't you, you tell me. Is this a bug?
>>
>> IDL> tt=stregex('cdefaz',"(.*)(a|b|c)z",/extract)
>> IDL> help,tt
>> TT STRING = 'cdefaz'
>>
>> My understanding of regular expressions says it's a bug. The first
>> '(.*)' should only match up to the 'a' and the second subexpression,
>> since it is *unqualified*, should handle the 'az', i.e. TT should
>> have two parts. tt[0] should be 'cdef' and tt[1] should be 'a.'
>
> Hi--
>
> Why don't you try the /SUBEXPR keyword? That seems to do the trick.
>



Well, duh! It's amazing what one can learn actually *reading* the
help file! ;-)

Thanks for pointing me to my rather obvious mistake.

whd
--
NOMINEE, n. A modest gentleman shrinking from the distinction of
private life and diligently seeking the honorable obscurity of public
office.
-- Ambrose Bierce: _The Devil's Dictionary_
Re: bug in stregex? [message #31529 is a reply to message #31526] Fri, 19 July 2002 15:16 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Vapuser <vapuser@catspaw.jpl.nasa.gov> writes:
> I don't you, you tell me. Is this a bug?
>
> IDL> tt=stregex('cdefaz',"(.*)(a|b|c)z",/extract)
> IDL> help,tt
> TT STRING = 'cdefaz'
>
> My understanding of regular expressions says it's a bug. The first
> '(.*)' should only match up to the 'a' and the second subexpression,
> since it is *unqualified*, should handle the 'az', i.e. TT should
> have two parts. tt[0] should be 'cdef' and tt[1] should be 'a.'

Hi--

Why don't you try the /SUBEXPR keyword? That seems to do the trick.

IDL> print, !version
{ x86 linux unix 5.4 Sep 25 2000 32 32}
IDL> print, stregex('cdefaz',"(.*)(a|b|c)z",/subexpr, /extract)
cdefaz cdef a

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: bug in stregex? [message #31531 is a reply to message #31529] Fri, 19 July 2002 14:53 Go to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Vapuser wrote:
>
> I don't you, you tell me. Is this a bug?
>
> IDL> tt=stregex('cdefaz',"(.*)(a|b|c)z",/extract)
> IDL> help,tt
> TT STRING = 'cdefaz'
>
> My understanding of regular expressions says it's a bug. The first
> '(.*)' should only match up to the 'a' and the second subexpression,
> since it is *unqualified*, should handle the 'az', i.e. TT should
> have two parts. tt[0] should be 'cdef' and tt[1] should be 'a.'

Try:

print,stregex('cdefaz',"(.*)([abc]z)",/subexpr,/extract)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: where are the user defined macros saved?
Next Topic: Urgent help! Could anyone send me a simple algorithm for Maximum Intensity Projection(MIP)?

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

Current Time: Wed Oct 08 15:50:28 PDT 2025

Total time taken to generate the page: 0.00523 seconds