[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Regular Expressions



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?

thanks, --Wayne Landsman
landsman@mpb.gsfc.nasa.gov