Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
adad99e9
Commit
adad99e9
authored
Jun 30, 2000
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added support for (?P=name)
(closes #3 and #7 from the status report)
parent
0da94b2b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
Lib/sre_parse.py
Lib/sre_parse.py
+17
-4
Lib/test/output/test_sre
Lib/test/output/test_sre
+0
-2
No files found.
Lib/sre_parse.py
View file @
adad99e9
...
...
@@ -189,9 +189,9 @@ def isname(name):
def _group(escape, groups):
# check if the escape string represents a valid group
try:
g
roup
= int(escape[1:])
if g
roup and group
< groups:
return g
roup
g
id
= int(escape[1:])
if g
id and gid
< groups:
return g
id
except ValueError:
pass
return None # not a valid group
...
...
@@ -442,7 +442,20 @@ def _parse(source, state, flags=0):
raise
error
,
"illegal character in group name"
elif
source
.
match
(
"="
):
# named backreference
raise
error
,
"not yet implemented"
name
=
""
while
1
:
char
=
source
.
get
()
if
char
is
None
:
raise
error
,
"unterminated name"
if
char
==
")"
:
break
name
=
name
+
char
if
not
isname
(
name
):
raise
error
,
"illegal character in group name"
gid
=
state
.
groupdict
.
get
(
name
)
if
gid
is
None
:
raise
error
,
"unknown group name"
subpattern
.
append
((
GROUP
,
gid
))
else
:
char
=
source
.
get
()
if
char
is
None
:
...
...
Lib/test/output/test_sre
View file @
adad99e9
test_sre
test_support -- test failed re module pickle
test_support -- test failed re module cPickle
=== Syntax error: ('(?P<foo_123>a)(?P=foo_123)', 'aa', 0, 'g1', 'a')
=== Failed incorrectly ('^(.+)?B', 'AB', 0, 'g1', 'A')
=== Failed incorrectly ('(a+)+\\1', 'aa', 0, 'found+"-"+g1', 'aa-a')
=== grouping error ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', 0, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/') 'd:msgs/tdir/sub1/-trial/' should be 'd:msgs/tdir/sub1/-tdir/'
=== Syntax error: ('(?P<id>aa)(?P=id)', 'aaaa', 0, 'found+"-"+id', 'aaaa-aa')
=== grouping error ('([abc])*bcd', 'abcd', 0, 'found+"-"+g1', 'abcd-a') 'abcd-c' should be 'abcd-a'
=== grouping error ('(?i)([abc])*bcd', 'ABCD', 0, 'found+"-"+g1', 'ABCD-A') 'ABCD-C' should be 'ABCD-A'
=== Syntax error: ('a(?!b).', 'abad', 0, 'found', 'ad')
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment