import sys import re if __name__ == "__main__": # 讀取第一行的n n = int(sys.stdin.readline().strip()) str = [] for i in range(n): # 讀取每一行 line = sys.stdin.readline().strip() # 匹配正則,匹配小寫字母和大寫字母的分界位置 p = re.compile(r'([A-Z][a-z]*)') # 這裏第二個參數使用了正則分組的後向引用 sub = re.findall(p, line) print(sub) ret = [] temp = '' for index, item in enumerate(sub): if len(item) > 1: if len(temp) > 1: ret.append(temp) temp = '' ret.append(item) else: temp += item if index == len(sub)-1: ret.append(temp) ret = [i.lower() for i in ret] str.append(ret) for i in str: print(str)