'''
思路:
定义一个函数匹配模式
一:利用正则表达式 匹配出单词的第一个辅音音素字母x
二:字母找出来后直接用str 的单词,减去x 然后 + xay

'''
import re
x = input('please enter your words:')
def game_pigwords(x):
reg = r'[^aeiou]'
pattern = re.compile(reg)
f_word = re.sub(pattern,'',x,count=1) # 用空值替代第一个辅音字母,获取去除一个字母的字符串
the_letter_objective = re.search(pattern,x) # search()和match()返回的是一个对象。
single_word = the_letter_objective.group() # 调用对象的方法则是 Objective.group()
the_pig_word = f_word + single_word +'ay'
return the_pig_word
#return f_word,single_word,the_pig_word
#print(fw)
print(game_pigwords(x))

# 用空值替代第一个辅音字母,获取去除一个字母的字符串,
# count 为计数次数,即替换的次数。count=0 是默认的全部替换,即符合条件的元素全部换掉。等于1 则换一个,按照先后顺序替换,以此类推
# 调用对象的方法则是 Objective.group()