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

Home » Public Forums » archive » regular expressions
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: Regular Expressions [message #24188 is a reply to message #15713] Thu, 15 March 2001 16:09 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Wayne Landsman wrote:
>
> The following is probably a simple question for anyone familiar with
> regular expressions, but I am still trying to learn the STREGEX
> function.
>
> Suppose I want to find the first occurence in a string of an 'l' ithat
> is not part of a double 'l'. For
> example, in the string
>
> IDL> st = 'The rolling hills and lake'
>
> I want to return the character position of the 'l' in lake (=21).
>
> The following expression almost works -- it will search for any 'l'
> which is both preceded and followed by anything that is not "l"
>
> IDL> print,stregex(st, '[^l]l[^l]' )
>
> but it won't work for the string 'The rolling hills and pool' because
> the final 'l' has no characters following it. Any suggestions?

IDL> print, stregex(st,'(^|[^l])l($|[^l])')

which means "a character that is not 'l', or the beginning of the
string, followed by an 'l', followed by a character that is not 'l', or
the end of the string". Aren't you glad Ken Thompson didn't decide
originally to develop regexps in english?

This will also work on

IDL> st = "let's all go the the movies"

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Time convertion
Next Topic: Re: curvefit Q

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

Current Time: Wed Oct 08 19:05:35 PDT 2025

Total time taken to generate the page: 0.00441 seconds