项目作者: blackhatGitHub

项目描述 :
re.match与re.serach的应用练习
高级语言:
项目地址: git://github.com/blackhatGitHub/re.serach.git
创建时间: 2017-11-10T06:03:05Z
项目社区:https://github.com/blackhatGitHub/re.serach

开源协议:

下载


!/usr/bin/python

-- coding: UTF-8 --

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type “copyright”, “credits” or “license()” for more information.

inport re.match
SyntaxError: invalid syntax
import re.match

Traceback (most recent call last):
File ““, line 1, in
import re.match
ImportError: No module named match

improt re
SyntaxError: invalid syntax
import re
line = ‘Cat are smarter than dogs’
matchobj = re.match(r’dogs’,line,re.M|re.I)
matchobj.group()

Traceback (most recent call last):
File ““, line 1, in
matchobj.group()
AttributeError: ‘NoneType’ object has no attribute ‘group’

matchobj = re.match(r’cat’,line,re.M|re.I)
matchobj.group()
‘Cat’
matchobj = re.search(r’are’,line,re.M|re.I)
print matchobj.group


print matchobj.group()
are
matchobj=re.serarch(r’^cat.*dogs$’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj=re.serarch(r’^cat.*dogs$’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)

File ““, line 2
matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)
^
IndentationError: unexpected indent

matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

line = ‘Cat are smarter than dogs’
matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’^cat.*dogs$’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.serarch(r’^cat .* dogs$’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’^cat .* dogs$’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.serarch(r’^Cat.*dogs$’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’^Cat.*dogs$’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.serarch(r’^cat’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’^cat’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.serarch(r’cat’,line,re.M|re.I)

Traceback (most recent call last):
File ““, line 1, in
matchobj = re.serarch(r’cat’,line,re.M|re.I)
AttributeError: ‘module’ object has no attribute ‘serarch’

matchobj = re.search(r’^cat.*dogs$’,line,re.M|re.I)
print matchobj.group


pint matchobj.group()
SyntaxError: invalid syntax
print matchobj.group()
Cat are smarter than dogs
matchobj = re.search(r’^cat’,line,re.M|re.I)
print matchobj.group()
Cat
line = ‘Cat are dogs simary than’
matchobj=re.search(r’dogs$’,line,re.M|re.I)
print matchobj.group()

Traceback (most recent call last):
File ““, line 1, in
print matchobj.group()
AttributeError: ‘NoneType’ object has no attribute ‘group’

matchobj=re.search(r’than$’,line,re.M|re.I)
print matchobj.group()
than