I want to calculate the number of Chinese letters and exclude some characters, for example,
s_l = ['康熙十年','咸丰三年','民国二十二年']
need to exempt ‘年’ character,so
s_l = ['康熙十年','咸丰三年','民国二十二年']
for idx, str_item in enumerate(s_l):
res = len(re.findall(r'[\u4E00-\u9FFF]', str_item))-len(re.findall(r'[年]', str_item))
print(res)
Now, can I combine these two regex to one? If so, how? It is not easy to combine directly to
re.findall(r'[\u4E00-\u9FFF]((?![年]).)*$', str_item)