Skip to content

Commit 1da8a6f

Browse files
committed
更新正则测试
1 parent 08130e2 commit 1da8a6f

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

test/test_re.py

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,48 @@ def test_has_key(html=u''):
8686
print '正常职位'
8787

8888

89+
def test_group(line):
90+
"""
91+
测试分组
92+
test_group('ip地址:127.0.0.1;')
93+
:return:
94+
"""
95+
# reip = re.compile(r'(?<![\.\d])(?:\d{1,3}\.){3}\d{1,3}(?![\.\d])')
96+
reip = re.compile(r'(?:\d{1,3}\.){3}\d{1,3}')
97+
for ip in reip.findall(line):
98+
print ip
99+
100+
101+
def test_group_02():
102+
"""
103+
测试分组
104+
:return:
105+
"""
106+
line = u"""{rootcatentry:{dispid:'1',name:'房产信息',listname:'house'},catentry:{dispid:'14',name:'商铺租售/生意转让',listname:'shangpu'},locallist:[{dispid:'2', name:'上海', listname:'sh'},{dispid:'1399', name:'黄浦', listname:'huangpu'},{dispid:'1421', name:'人民广场', listname:'renminguangchang'}],infoid:'27083373898050',userid:'39050173763341',linkman:'李经理'"""
107+
# reip = re.compile(r'(?<![\.\d])(?:\d{1,3}\.){3}\d{1,3}(?![\.\d])')
108+
re_local = re.compile(ur'(?:dispid:\'\d+\', name:\'(.*?)\')')
109+
for local in re_local.findall(line):
110+
print local
111+
112+
113+
def test_03():
114+
rule_company_name = ur'{"I":\d+,"V":"(.*?公司)"}'
115+
company_name_re_compile = re.compile(rule_company_name, re.I)
116+
for i in company_name_re_compile.findall(u'etwret{"I":123,"V":"上海啥啥啥有限公司"}werery'):
117+
print i
118+
119+
89120
if __name__ == '__main__':
90121
# print re_html(test_html)
91122

92-
93-
email_result = get_email(html_test)
94-
print json.dumps(email_result, ensure_ascii=False, indent=4)
95-
test_has_key(u'''某大型公司职位''')
123+
124+
# email_result = get_email(html_test)
125+
# print json.dumps(email_result, ensure_ascii=False, indent=4)
126+
# test_has_key(u'''某大型公司职位''')
127+
test_group('127.0.0.1')
128+
test_group('ip地址:127.0.0.1;')
129+
test_group_02()
130+
test_03()
96131

97132
"""
98133
测试结果

0 commit comments

Comments
 (0)