[oak perl] Regular Expressions

Belden Lyman blyman at iii.com
Fri Mar 12 12:30:36 CST 2004


On Thu, 2004-03-11 at 15:37, Tony Stubblebine wrote:
> Belden--
> 
> The lookahead is a positional construct. It has to match at the position 
> right before your alternation. Since there's another positional 
> construct in your lookahead (^), you've effectively anchored the entire 
> regex to the start of the string. In this case there isn't a vowel in 
> the first two letters of "strength."
> 

Got it! Thanks Tony.

> I suppose you could put a \w* between the lookahead and the alternation 
> clause. That would allow the lookahead to anchor at the start of the 
> string and your alternation to float across the rest of the string.
> 
> --Tony

At some point in my playing I discovered that

   /(?=^[A-z]+$).*?[aeiouy].*?/

does what I want. But I like

    (?=^[^aeiouy]{0,$max_consonants}[aeiouy])

better for this program.

Belden




More information about the Oakland mailing list