import re
pat="yue"
string="http://yum.iqianyue.com"
rst=re.search(pat,string)
print(rst)
pat1="\n"
string1='''dsfjsdjf
sdfsdfsdfsdf'''
rst1=re.search(pat1,string1)
print(rst1)
pat2="\w\dpython\w"
string2="hsdlfsga7pythonkdfshdskjf"
rst2=re.search(pat2,string2)
print(rst2)
pat3="pyth[jsz]n"
string3="fsdjfpythjnjslkdfpythsnjfsjpythjsnfsd"
rst3=re.search(pat3,string3)
print(rst3)
pat4=".python..."
string4="sjslkdjfpythonslfjshf"
rst4=re.search(pat4,string4)
print(rst4)
pat5="python|php"
string5="jfsdjphpjsljfspythonfsd"
rst5=re.search(pat5,string5)
print(rst5)
pat6="python"
pat7="python"
string6="sjljfaljafPythonsfjlsjfssfs"
rst6=re.search(pat6,string6)
print(rst6)
rst7=re.search(pat7,string6,re.I)
print(rst7)
pat8="p.*y"
pat9="p.*?y"
string8="jlsjfhspythonslfjshdpy"
rst8=re.search(pat8,string8)
rst9=re.search(pat9,string8)
print(rst8)
print(rst9)
string10="phskfhskjhfkjshfjksgjfyskjhfksdh"
rst10=re.match(pat8,string10)
print(rst10)
rst11=re.compile(pat8).findall(string10)
print(rst11)
pat="[a-zA-Z]+://[^\s]*[.com|.cn]"
string='<a href="http://www.baidu.com">fjsljflds</a>'
rst=re.compile(pat).findall(string)
print(rst)
pat="<p>(\d*?)</p>"
import urllib.request
data=urllib.request.urlopen("http://edu.csdn.net/huiyiCourse/detail/215").read()
rst=re.compile(pat).findall(str(data))
print(rst)
import urllib.request
import re
data=urllib.request.urlopen("https://read.douban.com/provider/all").read()
data=data.decode("utf-8")
pat='<div class="name">(.*?)</div>'
mydata=re.compile(pat).findall(data)
print(mydata)
fh=open("/Users/xubin/myapp/pythonfile/出版社file4.txt","w")
for i in range(0,len(mydata)):
fh.write(mydata[i]+"\n")
fh.close()