66import tkMessageBox
77import SearchEngine
88from SearchDialogBase import SearchDialogBase
9- import sre_parse
109
1110def replace (text ):
1211 root = text ._root ()
@@ -91,7 +90,7 @@ def replace_all(self, event=None):
9190 line , m = res
9291 chars = text .get ("%d.0" % line , "%d.0" % (line + 1 ))
9392 orig = m .group ()
94- new = self . _expand ( m , repl )
93+ new = m . expand ( repl )
9594 i , j = m .span ()
9695 first = "%d.%d" % (line , i )
9796 last = "%d.%d" % (line , j )
@@ -143,7 +142,7 @@ def do_replace(self):
143142 m = prog .match (chars , col )
144143 if not prog :
145144 return False
146- new = self . _expand ( m , self .replvar .get ())
145+ new = m . expand ( self .replvar .get ())
147146 text .mark_set ("insert" , first )
148147 text .undo_block_start ()
149148 if m .group ():
@@ -155,14 +154,6 @@ def do_replace(self):
155154 self .ok = 0
156155 return True
157156
158- def _expand (self , m , template ):
159- # XXX This code depends on internals of the regular expression
160- # engine! There's no standard API to do a substitution when you
161- # have already found the match. One should be added.
162- # XXX This parses the template over and over...
163- ptemplate = sre_parse .parse_template (template , m .re )
164- return sre_parse .expand_template (ptemplate , m )
165-
166157 def show_hit (self , first , last ):
167158 text = self .text
168159 text .mark_set ("insert" , first )
0 commit comments