question about grouping in RE

Shen Wang shenwang at e-mail.com
Thu Jan 4 22:03:03 EST 2001


Currently in RE (A)|(B)|(C) create 3 groups, I wonder if there is a way to
make it generate only 1 group. Which is more meaningful in my opinion. But
things are different for named group, in pattern like
(?P<name1>(sub1)(sub2))|(?P<name2>(pat1)), I did want (sub1) and (pat1)
refer to group 2, (sub2) refer to group 3, but I don't want group 'name1'
and 'name2' all refer to group 1, because then I have no way to tell which
part matchs. maybe we can change named group's number to negative?
That's all. I don't know if any guru can patch RE to add new flag like
"merge group name".






More information about the Python-list mailing list