1515import sys
1616import string
1717import marshal
18- import regex
18+ import re
1919
2020try :
2121 import Wthreading
2525 haveThreading = Wthreading .haveThreading
2626
2727_scriptuntitledcounter = 1
28- _wordchars = string .letters + string .digits + "_"
28+ # _wordchars = string.letters + string.digits + "_"
29+ _wordchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
2930
3031
3132runButtonLabels = ["Run all" , "Stop!" ]
@@ -553,7 +554,6 @@ def _runselection(self):
553554 if indent == 1 :
554555 classname = ''
555556 alllines = string .split (alltext , '\r ' )
556- identifieRE_match = _identifieRE .match
557557 for i in range (selfirstline - 1 , - 1 , - 1 ):
558558 line = alllines [i ]
559559 if line [:6 ] == 'class ' :
@@ -673,7 +673,6 @@ def flush(self):
673673
674674 def getclasslist (self ):
675675 from string import find , strip
676- import re
677676 methodRE = re .compile (r"\r[ \t]+def " )
678677 findMethod = methodRE .search
679678 editor = self .editgroup .editor
@@ -715,7 +714,6 @@ def getclasslist(self):
715714 offsetToLine = editor .ted .WEOffsetToLine
716715 getLineRange = editor .ted .WEGetLineRange
717716 append = classlist .append
718- identifieRE_match = _identifieRE .match
719717 for pos , tag in list :
720718 lineno = offsetToLine (pos )
721719 lineStart , lineEnd = getLineRange (lineno )
@@ -794,14 +792,13 @@ def _makewholewordpattern(word):
794792 # first, escape special regex chars
795793 for esc in "\\ [].*^+$?" :
796794 word = _escape (word , esc )
797- import regex
798795 notwordcharspat = '[^' + _wordchars + ']'
799- pattern = '\ (' + word + '\ )'
796+ pattern = '(' + word + ')'
800797 if word [0 ] in _wordchars :
801798 pattern = notwordcharspat + pattern
802799 if word [- 1 ] in _wordchars :
803800 pattern = pattern + notwordcharspat
804- return regex .compile (pattern )
801+ return re .compile (pattern )
805802
806803class SearchEngine :
807804
@@ -935,9 +932,9 @@ def replaceall(self):
935932 while 1 :
936933 if self .parms ["wholeword" ]:
937934 wholewordRE = _makewholewordpattern (find )
938- wholewordRE .search (text , pos )
939- if wholewordRE . regs :
940- pos = wholewordRE . regs [ 1 ][ 0 ]
935+ match = wholewordRE .search (text , pos )
936+ if match :
937+ pos = match . start ( 1 )
941938 else :
942939 pos = - 1
943940 else :
@@ -997,9 +994,9 @@ def findnext(self):
997994 selstart , selend = min (selstart , selend ), max (selstart , selend )
998995 if self .parms ["wholeword" ]:
999996 wholewordRE = _makewholewordpattern (find )
1000- wholewordRE .search (text , selend )
1001- if wholewordRE . regs :
1002- pos = wholewordRE . regs [ 1 ][ 0 ]
997+ match = wholewordRE .search (text , selend )
998+ if match :
999+ pos = match . start ( 1 )
10031000 else :
10041001 pos = - 1
10051002 else :
@@ -1009,9 +1006,9 @@ def findnext(self):
10091006 return 1
10101007 elif self .parms ["wrap" ]:
10111008 if self .parms ["wholeword" ]:
1012- wholewordRE .search (text , 0 )
1013- if wholewordRE . regs :
1014- pos = wholewordRE . regs [ 1 ][ 0 ]
1009+ match = wholewordRE .search (text , 0 )
1010+ if match :
1011+ pos = match . start ( 1 )
10151012 else :
10161013 pos = - 1
10171014 else :
@@ -1169,12 +1166,19 @@ def execstring(pytext, globals, locals, filename="<string>", debugging=0,
11691166 PyDebugger .stop ()
11701167
11711168
1172- _identifieRE = regex .compile ("[A-Za-z_][A-Za-z_0-9]*" )
1169+ _identifieRE = re .compile ("[A-Za-z_][A-Za-z_0-9]*" )
1170+
1171+ def identifieRE_match (str ):
1172+ match = _identifieRE .match (str )
1173+ if not match :
1174+ return - 1
1175+ return match .end ()
11731176
11741177def _filename_as_modname (fname ):
11751178 if fname [- 3 :] == '.py' :
11761179 modname = fname [:- 3 ]
1177- if _identifieRE .match (modname ) == len (modname ):
1180+ match = _identifieRE .match (modname )
1181+ if match and match .start () == 0 and match .end () == len (modname ):
11781182 return string .join (string .split (modname , '.' ), '_' )
11791183
11801184def findeditor (topwindow , fromtop = 0 ):
0 commit comments