
# ret = re.findall('janice','wertyujkjgjanicedfuygihujksaf')
# print(ret,type(ret))
# #findall('需要匹配的字符串','要处理的字符串')
#
#
# re.findall('janice$','wertyujkjgjanicedfuygihujksafjanice')
# re.findall('jan.*ce','wertyujkjanjgdfuygceihujksaf')
#
# re.findall('ja.{1,5}ice','wertjaabcdfdffdecesaf')
# re.findall('jan{,3}ice','python-jannnice-python')
#
# re.findall(pattern,string)
# #pattern: 匹配的条件
# #string: 需要匹配的字符串
#
# re.match(pattern,string,flags=0)
# #pattern: 匹配的条件
# #string: 需要匹配的字符串
# #flags:
#
# ret=re.match("com","comgoogle.com")
# re.match("com","comgoogle.com").group()
#
# re.match("com","comwww.runcomoob")


# re.search("com","google.com")
#
# re.sub(pattern,repl,string,max=0)
#pattern: 匹配的条件
#repl: 
#string: 需要匹配的字符串
#max:






# ret = re.sub("python","py","python is good! python is fun! python is easy!")

# # 在字符串裡以 py 替换全有 python 
# >>> ret = re.sub("python","py","python is good! python is fun! python is easy!")
# >>> ret
# 'py is good! py is fun! py is easy!'
# >>> type(ret)
# <class 'str'>

# # 在字符串裡以 py 替换共2個 python
# >>> ret = re.sub("python","py","python is good! python is fun! python is easy!",2)
# >>> ret
# 'py is good! py is fun! python is easy!'


# re.split(pattern,string)
# #pattern: 匹配的条件
# #repl: 
# #string: 需要匹配的字符串
# #max:

# re.split("\d+","one1two2three3four4")
# re.split("\d","one1two212three3four4")

import re
# origin = "has dfghjertyu45678"
# ret = re.match("h\w+",origin)
# ret1 = re.match("h(\w+)",origin)
# ret2 = re.match("h(?P<name>\w+)",origin)
#
# print(ret.group())
# print(ret1.groups())
# print(ret2.groupdict())


origin = "hasaabc dfjert halaabc yu45678"
ret = re.findall("h\w+",origin)
ret1 = re.findall("h(\w+)a(ab)c",origin)
ret2 = re.findall("h(?P<name>\w+)",origin)

print(ret)
print(ret1)
print(ret2)





