From: Johan Andersson <johan.rejeep@gmail.com>
To: "Pascal J. Bourguignon" <pjb@informatimago.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Group at several places in string
Date: Wed, 13 Jan 2010 08:36:34 +0000 [thread overview]
Message-ID: <929ccd881001130036y3c5badd2qfbe792edb298fe98@mail.gmail.com> (raw)
In-Reply-To: <87y6k2n9of.fsf@hubble.informatimago.com>
[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]
Pascal,
Really cool solution! I have never seen something like it.
Thanks a lot. Tons better than my solution!
On Wed, Jan 13, 2010 at 12:13 AM, Pascal J. Bourguignon <
pjb@informatimago.com> wrote:
> Johan Andersson <johan.rejeep@gmail.com> writes:
> > I have string that contains smaller chunks of text, which are wrapped
> within double quotes. Example:
> > Lorem ipsum dolor sit amet, "consectetur" adipiscing elit. Donec
> "suscipit justo" sit amet sem bibendum "sit amet" porttitor mi
> > pretium.
> >
> > I'm looking for a way to add all the chunks in double quotes in a list.
> So in this case:
> > '("consectetur" "suscipit justo" "sit amet")
> >
> > I have created such a function with help of some while loops and whatever
> else. But I thought that it could be done with some regex
> > like this "\"\\([^\"]+\\)\"" and then fetch the groupings. But it does
> not work.
> >
> > How would you solve this?
>
> Here is a simple solution:
>
> (defun parts-in-double-quotes (input)
> (loop for sub on (cdr (split-string input "\"")) by (function cddr)
> collect (car sub)))
>
> (parts-in-double-quotes "Lorem ipsum dolor sit amet, \"consectetur\"
> adipiscing elit. Donec \"suscipit justo\" sit amet sem bibendum \"sit amet\"
> porttitor mi pretium.")
> --> ("consectetur" "suscipit justo" "sit amet")
>
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
>
[-- Attachment #2: Type: text/html, Size: 2131 bytes --]
next prev parent reply other threads:[~2010-01-13 8:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1289.1263338646.18930.help-gnu-emacs@gnu.org>
2010-01-13 0:13 ` Group at several places in string Pascal J. Bourguignon
2010-01-13 8:36 ` Johan Andersson [this message]
2010-01-12 23:23 Johan Andersson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=929ccd881001130036y3c5badd2qfbe792edb298fe98@mail.gmail.com \
--to=johan.rejeep@gmail.com \
--cc=help-gnu-emacs@gnu.org \
--cc=pjb@informatimago.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.