homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients docs@python, ezio.melotti, mrabarnett, r.david.murray, triquetra011
Date 2013年04月09日.06:21:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1365488484.52.0.485966076314.issue17668@psf.upfronthosting.co.za>
In-reply-to
Content
Only group the stuff you want to see in the result:
>>> re.split(r'(^>.*$)', '>Homo sapiens catenin (cadherin-associated)')
['', '>Homo sapiens catenin (cadherin-associated)', '']
>>> re.split(r'^(>.*)$', '>Homo sapiens catenin (cadherin-associated)')
['', '>Homo sapiens catenin (cadherin-associated)', '']
If you are using grouping to get alternatives, you can use a non-capturing group:
>>> re.split(r'(ca(?:t|d))', '>Homo sapiens catenin (cadherin-associated)')
['>Homo sapiens ', 'cat', 'enin (', 'cad', 'herin-associated)']
(By the way, I'm a bit confused as to what exactly you are splitting in your original example, since you seem to be matching the whole string, and only if it is the whole string. On the other hand, regular expressions regularly confuse me... :)
I indeed do not think it is worth complicating the interface to handle the unusual case of accepting and applying unknown regexes. The one change I could see as a possibility would be to allow all of the groups matched by the split regex to appear as a single sublist. But I'm not the maintainer of this module either :)
History
Date User Action Args
2013年04月09日 06:21:24r.david.murraysetrecipients: + r.david.murray, ezio.melotti, mrabarnett, docs@python, triquetra011
2013年04月09日 06:21:24r.david.murraysetmessageid: <1365488484.52.0.485966076314.issue17668@psf.upfronthosting.co.za>
2013年04月09日 06:21:24r.david.murraylinkissue17668 messages
2013年04月09日 06:21:24r.david.murraycreate

AltStyle によって変換されたページ (->オリジナル) /