redemo.py with named groups

M

moriwaka

Hi,
I wrote an easy patch for redemo.py to print named groups.

For example,

regexp: (?P<spam>.*)
string: foobar

shows following groups.

Groups:
0: 'foobar'
1: 'foobar'
'spam': 'foobar'

I don't know how/where to commit this patch..
any suggestions?

--- Tools/scripts/redemo.py 2004-02-13 02:35:32.000000000 +0900
+++ redemo.py 2006-08-21 01:11:11.000000000 +0900
@@ -148,6 +148,10 @@
for i in range(len(groups)):
g = "%2d: %r" % (i, groups)
self.grouplist.insert(END, g)
+ groupdict = m.groupdict()
+ for key in groupdict:
+ g = "%r: %r" % (key, groupdict[key])
+ self.grouplist.insert(END, g)
nmatches = nmatches + 1
if self.showvar.get() == "first":
break
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top