Last active
May 12, 2016 12:57
-
-
Save zeroxia/342c6718514db5c08140fbeea8cfeec0 to your computer and use it in GitHub Desktop.
Find lines with equal "left" and "right" parts that are separated by the Chinese comma ","
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# vim: set ts=4 et: | |
import re | |
p = re.compile("^(.*),(.*)。$") | |
with open("input.txt") as f: | |
for lno, line in enumerate(f): | |
mo = p.match(line.rstrip()) | |
if mo: | |
if mo.end(1) - mo.start(1) == mo.end(2) - mo.start(2): | |
print("{:3d}: YES: [{}] == [{}]".format(lno + 1, mo.group(1), mo.group(2))) | |
else: | |
print("{:3d}: NO: [{}] != [{}]".format(lno + 1, mo.group(1), mo.group(2))) | |
# Sample input.txt: | |
""" | |
降成本,补短板。 | |
稳中有进,稳中有好。 | |
回顾过去一年,成绩来之不易。 | |
回顾过过去一年,成绩来之bb不易。 | |
提高利用外资水平,继续放宽投资准入。 | |
你好,OK。 | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment