[Python-Dev] Re: re.split on empty patterns (original) (raw)
Brett C. bac at OCF.Berkeley.EDU
Fri Aug 13 04:46:10 CEST 2004
- Previous message: [Python-Dev] Re: re.split on empty patterns
- Next message: [Python-Dev] Re: re.split on empty patterns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mike Coleman wrote:
[SNIP]
# alternative 2: re.structmatch(r'xxx|(?=abc)', 'zzxxxabczz') --> ['zz', 'bbczz'] ^ re.structmatch(r'xxx|(?=abc)', 'zzxxxbbczz') --> ['zz', 'bbczz']
# alternative 3: re.structmatch(r'xxx|(?=abc)', 'zzxxxabczz') --> ['zz', '', 'bbczz'] ^ re.structmatch(r'xxx|(?=abc)', 'zzxxxbbczz') --> ['zz', 'bbczz']
I take it the first 'b' in both of the first examples for each alternative were supposed to be 'a'?
And as for which version, I actually like Mike's version more than the one AMK and Tim like. The reason is that the '' in the middle of the example in question in the OP tells you where the split would have occurred had split0 (I like that or 'split_empty') not been turned on. That way there is no real loss of data between the two, but a gain with the new feature being used.
-Brett
- Previous message: [Python-Dev] Re: re.split on empty patterns
- Next message: [Python-Dev] Re: re.split on empty patterns
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]