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 #24195 is a reply to message #24188] Thu, 15 March 2001 19:24 Go to previous messageGo to previous message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
JD Smith wrote:

> 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"

Thanks. But I now realize that my original formulation was not quite
correct, since the above expression (usually!) returns the position of the
character *before* the 'l', so to get the position of the first single 'l'
one has to add 1

IDL> l_position = stregex(st,'(^|[^l])l($|[^l])') + 1

Unfortunately, if 'l' is the first character, then you *don't* want to add
the 1. (The expression stregex(st,'(^|[^l])l($|[^l])') returns a value of
0 for both st ='long days' and st ='slow nights'. )
One solution is to forget about the beginning of string anchor and just
concatenate a blank to the beginning to the string

IDL> l_position = stregex(' ' + st,'[^l]l($|[^l])')

--Wayne

P.S. The real-life problem I am working on deals not with 'l' but with
apostrophes. I am trying to speed up the processing of FITS header
values, where is a string is delineated by non-repeating apostrophes, and a
possessive is indicated by a double apostrophe.

VALUE = 'This is Wayne''s FITS value' / Example string field
[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:27:14 PDT 2025

Total time taken to generate the page: 0.00487 seconds