# -*- coding:utf-8 -*-
import re
import sys
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
s="abcd bcde fdsa"
ret = re.findall(r'a?b\w+\b' , s)
print(ret)
# s = '<div class="a">1111</div><aa>'
# ret = re.findall(r'</?div.*?>' , s)
# print(ret)
#获取长度为3个字母的单词
# s = "min tian jiu yao fang jia le ,da jia"
# ret = re.findall(r'\b\w{3}\b' , s)
# print(ret)
# 把重复的字符集合只保留一个
# s = "我是我是我真的是你是你是你真的是"
# res = re.compile(r'(我|你)是\1+')
# ret = res.sub(r'\1' , s)
# print(ret)
#把重复的字符只保留一个
# s = "我我我是你你的爱我"
# res = re.compile(r'(我|你)\1+')
# ret = res.sub(r'\1' , s)
# print(ret)
#把重复的替换成&
# s = "我我我是你你的爱我"
# res = re.compile(r'(我|你)\1+')
# res = re.compile(r'(我|你){1,}')
# ret = res.sub('&' , s)
# print(ret)
#找出以字母e结尾的单词,忽略大小写
# s = 'THREE people at HERE do some THING tree'
# res = re.compile(r'\w+e\b' , re.I) #\b为边界
# ret = res.findall(s)
# print(ret)
#根据某个关键字提取
# s = "湖北省武汉市"
# res = re.compile(r'(.*)省')
# ret = res.findall(s)
# for item in ret:
# print(item.decode('utf-8'))
#替换连续出现两次aa
# s = "我是我a我是不一样的烟火aa你又是谁aaa但你是谁"
# res = re.compile(r'\w{2,}')
# ret = res.sub('' , s)
# print(ret)
#把-替换成*
# str = "我是我-我是不一样的烟火-你又是谁---但你是谁"
# res = re.compile(r'-')
# ret = res.sub('*', str)
# print(str)
#根据空格切割字符串
# str = "我是我 我是不一样的烟火 你又是谁 但你是谁"
# res = re.compile(r'\s*')
# ret = res.split(str)
# for item in ret:
# print(item)
#查询字符串中我的个数
# str = "我是我,我是不一样的烟火,你又是谁"
# ret = re.findall(r'(我|你)' ,str)
# print(len(ret))
#$匹配以来自...。
# s = "内容本次新闻来自大学生协助。"
# s1 = "内容本次新闻来大学生协助。"
# s2 = "内容本次新闻来自大学生协助"
# ret = re.match(r'.*(来自\S*。)$',s)
# ret1 = re.match(r'.*(来自\S*。)$',s1)
# ret2 = re.match(r'.*(来自\S*。)$',s2)
# print(ret.group())
# print(ret1)
# print(ret2)
# ^匹配以X开头的
# s = '我是对的,但没错'
# s1 = '你我是对的,但没错'
# ret = re.match(r'我.*',s)
# ret1 = re.match(r'^我.*',s1)
# ret2 = re.match(r'^我.*',s)
# print(ret.group())
# print(ret1)
# print(ret2.group())
#30~60
var reg=/^[3-6][0-9]$/;
#70~105
var reg=/^([7-9][0-9])|(10[0-5])$/;
#110~150
#var reg=/^(1[1-4][0-9])|150$/;