mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
save match function instead of regexp object
This commit is contained in:
parent
14d53bf164
commit
dff84043e4
2 changed files with 4 additions and 4 deletions
|
@ -4,14 +4,14 @@ import regexp
|
|||
import string
|
||||
|
||||
def grep(expr, filename):
|
||||
prog = regexp.compile(expr)
|
||||
match = regexp.compile(expr).match
|
||||
fp = open(filename, 'r')
|
||||
lineno = 0
|
||||
while 1:
|
||||
line = fp.readline()
|
||||
if not line: break
|
||||
lineno = lineno + 1
|
||||
res = prog.exec(line)
|
||||
res = match(line)
|
||||
if res:
|
||||
#print res
|
||||
start, end = res[0]
|
||||
|
|
|
@ -4,14 +4,14 @@ import regexp
|
|||
import string
|
||||
|
||||
def grep(expr, filename):
|
||||
prog = regexp.compile(expr)
|
||||
match = regexp.compile(expr).match
|
||||
fp = open(filename, 'r')
|
||||
lineno = 0
|
||||
while 1:
|
||||
line = fp.readline()
|
||||
if not line: break
|
||||
lineno = lineno + 1
|
||||
res = prog.exec(line)
|
||||
res = match(line)
|
||||
if res:
|
||||
#print res
|
||||
start, end = res[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue