Re: bug in stregex? [message #31526] |
Fri, 19 July 2002 18:07 |
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  |
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  |
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)
|
|
|