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

Home » Public Forums » archive » Re: stregex question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: stregex question [message #67221] Tue, 21 July 2009 09:53 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
wlandsman wrote:
> I'd like to find the first "e" in a string that is not next to
> another "e"
>
> The solution
> stregex(s,"e[^e]|$") ;"e" followed by not "e" or at the end of the
> line
> doesn't work for the string st = 'see me' because it will find the
> second "e" in "see"
>
> The soluton
> stregex(s,"e{1}") ;Find one occurrence of "e"
> also finds the first "e" in "see" (Two occurrences is also one
> occurrence)
>
> In Perl it seems that one would use the "lookahead" option, but that
> doesn't seem to be available in stregex().
>
> (Actually I am looking for the first quote that is not part of a
> double quote, but I wanted to keep the example syntax simple.)
> Thanks, --Wayne

I would do something like:

IDL> pos = stregex(s, '([^e]e[^e])|(^e[^e])|(^e$)|([^e]e$)')
IDL> pos += strmid(s, pos, 1) ne 'e'

You have to add one to pos if either the [^e]e[^e] or [^e]e$ forms matched.

Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: IDL KML
Next Topic: IDL question about IMSL_NLINLSQ

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

Current Time: Fri Oct 10 14:15:26 PDT 2025

Total time taken to generate the page: 0.56225 seconds