2 # -*- coding: utf-8 -*-
9 fh_in = codecs.getreader('utf_8')(sys.stdin)
10 fh_out = codecs.getwriter('utf_8')(sys.stdout)
11 sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
13 rex1 = re.compile(ur"^☆図([0-9]+)\s+")
14 rex2 = re.compile(ur"\*図([0-9]+)")
15 rex3 = re.compile(ur"\*図([0-9]+)[〜~]([0-9]+)")
16 rex4 = re.compile(ur"\*図([0-9]+)、([0-9]+)")
27 l = rex1.sub(ur"☆図%d " % (counter_ref,), l)
30 ref1 = int(m3.group(1))
31 ref2 = int(m3.group(2))
32 l = rex3.sub(ur"*図%d~%d" % (counter_fig, counter_fig+ref2-ref1), l)
33 counter_fig += ref2 - ref1 + 1
35 ref1 = int(m4.group(1))
36 ref2 = int(m4.group(2))
37 l = rex4.sub(ur"*図%d、%d" % (counter_fig, counter_fig+ref2-ref1), l)
38 counter_fig += ref2 - ref1 + 1
40 l = rex2.sub(ur"*図%d" % (counter_fig,), l)