Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dff8404

Browse files
committed
save match function instead of regexp object
1 parent 14d53bf commit dff8404

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/grep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import string
55

66
def grep(expr, filename):
7-
prog = regexp.compile(expr)
7+
match = regexp.compile(expr).match
88
fp = open(filename, 'r')
99
lineno = 0
1010
while 1:
1111
line = fp.readline()
1212
if not line: break
1313
lineno = lineno + 1
14-
res = prog.exec(line)
14+
res = match(line)
1515
if res:
1616
#print res
1717
start, end = res[0]

Lib/lib-old/grep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
import string
55

66
def grep(expr, filename):
7-
prog = regexp.compile(expr)
7+
match = regexp.compile(expr).match
88
fp = open(filename, 'r')
99
lineno = 0
1010
while 1:
1111
line = fp.readline()
1212
if not line: break
1313
lineno = lineno + 1
14-
res = prog.exec(line)
14+
res = match(line)
1515
if res:
1616
#print res
1717
start, end = res[0]

0 commit comments

Comments
 (0)