Add a page number to the back of the bookmark, like this:
s = "\t\t1.12 first section \t36", equivalent to the last \ T location plus page numbers, you can:
① can reverse the string, and then Str.split () once, plus the page number; ② uses Re.split () to locate the last \ T, split
#!/usr/bin/python
#coding:utf-8
#2015-12-22 11:53:30.469000
"""
"""
import sys
reload(sys)
sys.setdefaultencoding(‘utf8‘)
import re
s = "\t\t1.12 第一节\t36"
pat = r"\t(?=\d+$)"
print re.split(pat,s)
‘‘‘
re.split(pattern, string, maxsplit=0, flags=0)
会用pattern匹配到的字符作为分隔符,对string进行分割,产生一个list,list里没有分割符;
如果pattern里有圆括号(组),分隔符也会作为组出现在结果的list里;
pat = r"\t(?=\d+$)" [‘\t\t1.12 zhang‘, ‘36‘]
匹配到最后一个"\t"
pat = r"\t(\d+$)" [‘\t\t1.12 zhang‘, ‘36‘, ‘‘]
匹配到了最后的"\t"和"36",36在括号里是组,所以显示出来;
pat = r"\t(?:\d+$)" [‘\t\t1.12 zhang‘, ‘‘]
匹配到了"\t36"
‘‘‘
From for notes (Wiz)
12. Regular _pdf bookmark plus page number