in reply to Another regex to solve ...

I've not done much testing but this seems to work by putting the capture in the look-behind.

knoppix@Microknoppix:~$ perl -E ' > for ( qw{ soap creep top groat loop } ) > { > say unless m{(?<=([aeiou]))\1p\z}; > }' soap top groat knoppix@Microknoppix:~$

I hope this is helpful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: Another regex to solve ...
by Not_a_Number (Prior) on Aug 18, 2011 at 23:34 UTC
        say unless m{(?<=([aeiou]))\1p\z};

    That allows eg 'help' or slurp'.

    Update: I've no idea why though, or why it also allows 'hops' and 'hoops'...

    Update 2: Got it! It also of course allows 'rabbit', or any other string that doesn't end in 'p' preceded by whatever. It was the unless that momentarily confused me. :)

      Yes, that was a pretty woeful attempt on my part. I must have been thinking about a sub-set of words all ending with 'p' rather than the general case :-(

      Cheers,

      JohnGG

Re^2: Another regex to solve ...
by pat_mc (Pilgrim) on Aug 19, 2011 at 19:35 UTC
    Hi, johngg -

    I like the approach of back-referencing the match from the look-behing ... the only issue I have with the code you propose is that it over-generates in the sense that it will also pass strings all other strings that do not match the regex like 'stp' ... and that, of course, it shouldn't since we only want words to pass that have a non-double vowels in front of the word-terminal 'p'.