in reply to Perl Golf (was RE: (Ovid) RE: Pig Latin)
in thread Pig Latin
japhy, originally, I was constructing a rather longer and optimized script to do the pig latin conversion. Then I went back and reread vroom's specs. First, I didn't use the /i modifier because he said we were to assume the data was lowercase and he wanted the shortest possible code.
The reason I am using three backreferences is because the data saved to $2 is tricky. Your equivalent (ignoring the "qu" problem) is [^\W0-9_]. This allows you to match all alphabeticals but does no discrimination for vowels. However, you apeared to notice this when you mentioned [b-df-hj-np-tv-z]. Therefore, I suspect that you intended the following and (assuming you did intend this) I offer you kudos for a clever regex:
I also noticed that, in this case, using the /i modifier ignored vroom's "lowercase" spec, but does result in a shorter regex.s/\b(qu|[^\W0-9_aeiou]+)?([a-z]+)/$1?"$2$1ay":"$2way"/ieg;
Cheers,
Ovid
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: (Ovid) RE: Perl Golf
by japhy (Canon) on Jul 24, 2000 at 00:00 UTC | |
by ybiC (Prior) on Jul 24, 2000 at 02:38 UTC | |
by japhy (Canon) on Jul 24, 2000 at 02:54 UTC | |
by Ovid (Cardinal) on Jul 24, 2000 at 03:10 UTC |
In Section
Seekers of Perl Wisdom