Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Re.sub + lambda solution in Clear category for Bird Language by ural_gorets
import re
def translation(phrase):
'''
This function use Regular Expressions for search patterns meets task's conditions.
It uses "re.sub" function to replace found pattern with another required by
task conditions.
a{3,4} = 3 or 4 letters "a" one by other. With other wovels the same.
[^aeiouy ]\w = a letter not from list in square brackets (which will be consonant)
+ 1 any letter next to it (which is required to remove by task's conditions).
And now the very delicious: "sub" can use the lambda function to receive search
result, which is match-object, modify it, and use as a replacement for found pattern.
To extract found string from match-object used "group" method. If it used
with zero as argument, or without any argument, it returns whole substring
meets pattern. And then possible to work with this string as usual.
'''
return re.sub(r'a{3,4}|e{3,4}|i{3,4}|o{3,4}|u{3,4}|y{3,4}|[^aeiouy ]\w',
lambda match: match.group()[0] , phrase)
Sept. 10, 2018