Skip to content

Instantly share code, notes, and snippets.

@cuihaoleo
Created October 7, 2014 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cuihaoleo/675db3a2bd8c9bbbbf9b to your computer and use it in GitHub Desktop.
Save cuihaoleo/675db3a2bd8c9bbbbf9b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import re
import sys
prog = re.compile(r"\\N(?:{[^{}]*})?")
prog2 = re.compile(r"(Dialogue: \w*,\w*:\w*:\w*.\w*,\w*:\w*:\w*.\w*,\w*,\w*,\w*,\w*,\w*,\w*,)(.*)")
for line in sys.stdin:
if line.startswith("Dialogue"):
mt = prog2.match(line)
if mt and len(mt.groups()) == 2:
a, b = mt.groups()
sp = prog.split(b)
if len(sp) == 2:
print((a+sp[0]).strip(), file=sys.stderr)
print((a+sp[1]).strip(), file=sys.stdout)
continue
print(line.strip(), file=sys.stderr)
if not re.findall(r'[\u4e00-\u9fff]+', line):
print(line.strip(), file=sys.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment