re
__author__ = 'scott'
import re
line = "boby123"
if line == "boby123":
print("equal:ture")
reg_str = "^b.*3$"
if re.match(reg_str,line):
print("mathced")
else:
print("not matched")
line2 = "boooooobbay123"
match_str = ".*?(b.*?b).*"
match_obj = re.match(match_str,line2)
if match_obj:
print(match_obj.group(1))
line3 ="boooobbby123"
match_str = ".*(b.+b).*"
if re.match(match_str,line3):
print(re.match(match_str,line3).group(1))
line4 = "bobby123"
match_str = "((boby|bobby)123)"
match_obj = re.match(match_str,line4)
if match_obj:
print(match_obj.group(1))
print(match_obj.group(2))
line5 = "bobby123"
match_str = "([abcd]obby123)"
match_obj = re.match(match_str,line4)
if match_obj:
print(match_obj.group(1))
line6 = "你 好"
match_str = "(你\s好)"
match_obj = re.match(match_str,line6)
if match_obj:
print(match_obj.group(1))
line6 = "你sa好"
match_str = "(你\S+好)"
match_obj = re.match(match_str,line6)
if match_obj:
print(match_obj.group(1))
line6 = "你 好s"
match_str = "([\u4E00-\u9FA5]+)"
match_obj = re.match(match_str,line6)
if match_obj:
print(match_obj.group(1))
line6 = "study in 南京大学"
match_str = ".*?([\u4E00-\u9FA5]+大学)"
match_obj = re.match(match_str,line6)
if match_obj:
print(match_obj.group(1))
line6 = "xxx出生于2012年"
match_str = ".*?(\d+)年"
match_obj = re.match(match_str,line6)
if match_obj:
print(match_obj.group(1))
111