mirror of
https://github.com/python/cpython.git
synced 2025-08-27 20:25:18 +00:00
Convert all remaining *simple* cases of regex usage to re usage.
This commit is contained in:
parent
426916e50e
commit
9694fcab53
23 changed files with 134 additions and 144 deletions
|
@ -266,15 +266,15 @@ def expandvars(path):
|
|||
if '$' not in path:
|
||||
return path
|
||||
if not _varprog:
|
||||
import regex
|
||||
_varprog = regex.compile('$\([a-zA-Z0-9_]+\|{[^}]*}\)')
|
||||
import re
|
||||
_varprog = re.compile(r'\$(\w+|\{[^}]*\})')
|
||||
i = 0
|
||||
while 1:
|
||||
i = _varprog.search(path, i)
|
||||
if i < 0:
|
||||
m = _varprog.search(path, i)
|
||||
if not m:
|
||||
break
|
||||
name = _varprog.group(1)
|
||||
j = i + len(_varprog.group(0))
|
||||
i, j = m.span(0)
|
||||
name = m.group(1)
|
||||
if name[:1] == '{' and name[-1:] == '}':
|
||||
name = name[1:-1]
|
||||
if os.environ.has_key(name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue