From: Daniel Hartwig <mandyke@gmail.com>
To: guile-devel@gnu.org
Subject: Re: [PATCH] add regexp-split
Date: Fri, 30 Dec 2011 17:42:16 +0800 [thread overview]
Message-ID: <CAN3veRfRK7YN9YKrkJyg52T763f1fP3F6n0dTZ7+U9BX5O8HHw@mail.gmail.com> (raw)
In-Reply-To: <CAN3veRdFQyOthFTSLE7v9x3_A4HTPX99DSmDx26dBkeyy=MTDQ@mail.gmail.com>
On 30 December 2011 16:46, Nala Ginrut <nalaginrut@gmail.com> wrote:
> hi Daniel! Very glad to see your reply.
> 1. I also think the order: (regexp str) is strange. But it's according to
> python version.
> And I think the 'string-match' also put regexp before str. Anyway, that's an
> easy mend.
`regexp string' is also the same order as `list-matches' and
`fold-matches'. Probably best to keep it that way if this is in the
regex module.
>> I would like to see your version support the Python semantics [1]:
>>
>> > If capturing parentheses are used in pattern, then the text of
>> > all groups in the pattern are also returned as part of the resulting
>> > list.
>> [...]
>> > >>> re.split('\W+', 'Words, words, words.')
>> > ['Words', 'words', 'words', '']
>> > >>> re.split('(\W+)', 'Words, words, words.')
>> > ['Words', ', ', 'words', ', ', 'words', '.', '']
>>
>> >>> re.split('((,)?\W+?)', 'Words, words, words.')
>> ['Words', ', ', ',', 'words', ', ', ',', 'words', '.', None, '']
FYI this can be achieved by changing the inner part to:
(let* ...
(s (substring string start end))
(groups (map (lambda (n) (match:substring m n))
(iota (1- (match:count m)) 1))))
(list `(,@ll ,s ,@groups) (match:end m) tail)))
Note: using srfi-1 iota
next prev parent reply other threads:[~2011-12-30 9:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-29 9:32 [PATCH] add regexp-split Nala Ginrut
2011-12-29 9:46 ` Nala Ginrut
2011-12-29 10:20 ` Nala Ginrut
2011-12-29 13:58 ` Nala Ginrut
2011-12-30 5:34 ` Daniel Hartwig
2011-12-30 8:46 ` Nala Ginrut
2011-12-30 9:05 ` Nala Ginrut
[not found] ` <CAN3veRdFQyOthFTSLE7v9x3_A4HTPX99DSmDx26dBkeyy=MTDQ@mail.gmail.com>
2011-12-30 9:42 ` Daniel Hartwig [this message]
2011-12-30 11:40 ` Nala Ginrut
2011-12-30 11:47 ` Nala Ginrut
2011-12-30 15:23 ` Daniel Hartwig
2011-12-30 10:14 ` Marijn
2011-12-30 10:56 ` Nala Ginrut
2011-12-30 11:48 ` Marijn
2011-12-30 11:52 ` Nala Ginrut
2011-12-30 13:23 ` Marijn
2011-12-30 14:57 ` Daniel Hartwig
2011-12-31 1:46 ` Daniel Hartwig
2011-12-31 2:32 ` Eli Barzilay
2011-12-31 3:16 ` Daniel Hartwig
2011-12-31 3:21 ` Eli Barzilay
2011-12-31 4:37 ` Daniel Hartwig
2011-12-31 7:00 ` Eli Barzilay
2011-12-30 13:03 ` Neil Jerram
2011-12-30 15:12 ` Nala Ginrut
2011-12-30 16:26 ` Neil Jerram
2011-12-30 16:46 ` Nala Ginrut
2012-01-07 22:44 ` Andy Wingo
2011-12-30 15:33 ` Daniel Hartwig
2011-12-30 15:58 ` Nala Ginrut
-- strict thread matches above, loose matches on Subject: below --
2013-02-01 9:24 Nala Ginrut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAN3veRfRK7YN9YKrkJyg52T763f1fP3F6n0dTZ7+U9BX5O8HHw@mail.gmail.com \
--to=mandyke@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).