From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Johan Andersson Newsgroups: gmane.emacs.help Subject: Re: Group at several places in string Date: Wed, 13 Jan 2010 08:36:34 +0000 Message-ID: <929ccd881001130036y3c5badd2qfbe792edb298fe98@mail.gmail.com> References: <87y6k2n9of.fsf@hubble.informatimago.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0016e6d77eac037391047d07abc7 X-Trace: ger.gmane.org 1263371840 24180 80.91.229.12 (13 Jan 2010 08:37:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Jan 2010 08:37:20 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 13 09:37:12 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NUyiw-0008UK-Dr for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jan 2010 09:37:07 +0100 Original-Received: from localhost ([127.0.0.1]:42426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUyiv-0001fN-1m for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jan 2010 03:37:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NUyiW-0001f2-SY for help-gnu-emacs@gnu.org; Wed, 13 Jan 2010 03:36:40 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NUyiS-0001bf-5e for help-gnu-emacs@gnu.org; Wed, 13 Jan 2010 03:36:40 -0500 Original-Received: from [199.232.76.173] (port=55541 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NUyiS-0001bW-38 for help-gnu-emacs@gnu.org; Wed, 13 Jan 2010 03:36:36 -0500 Original-Received: from mail-ew0-f209.google.com ([209.85.219.209]:58391) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NUyiR-0001J8-9t for help-gnu-emacs@gnu.org; Wed, 13 Jan 2010 03:36:35 -0500 Original-Received: by ewy1 with SMTP id 1so147344ewy.8 for ; Wed, 13 Jan 2010 00:36:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=DdIVm0Z5b45X6YU7TLuu+HKkCo1jelj+hjrGlKgA9S4=; b=EUuiwoBMOdHN5Q+AfjYlSpzUPXhfi/9Geil7gkbdVwVkgvQd8+J4T+Bz43Qrsfd73S q+4U4zvdD9BYRcqCCiv/lStQ1S6AQqi68huZjmy3z2BakugZcbpel3OJiyE5LQ3PT6Ny Z3RDuSOMt7DaLxFP+CB/W9HqCDOeG3bCnmT3s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=V5cxRyRwo031Kri3o2F/XnPrNLxTW/k+Euwt109qvCCy6iYAeaBqvlybCCr0uNrLSh mElarRg6mW/BSnmlZg8OL7ONg8wJggqEZSZaytzsb/0WgQZmHTstDsPDQi6J//Lovo9q TTypKh7JnvlfbYns4968QJmE4uOefzzE3vGYc= Original-Received: by 10.216.93.74 with SMTP id k52mr1721375wef.144.1263371794215; Wed, 13 Jan 2010 00:36:34 -0800 (PST) In-Reply-To: <87y6k2n9of.fsf@hubble.informatimago.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71201 Archived-At: --0016e6d77eac037391047d07abc7 Content-Type: text/plain; charset=ISO-8859-1 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 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/ > --0016e6d77eac037391047d07abc7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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:
<= div class=3D"h5">Johan Andersson <johan.rejeep@gmail.com> writes:
> I have string that contains smaller chunks of text, which=A0 are wrapp= ed within double quotes. Example:
> Lorem ipsum dolor sit amet, "consectetur" adipiscing elit. D= onec "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 ame= t")
>
> I have created such a function with help of some while loops and whate= ver else. But I thought that it could be done with some regex
> like this "\"\\([^\"]+\\)\"" and then fetch t= he groupings. But it does not work.
>
> How would you solve this?

Here is a simple solution:

(defun parts-in-double-quotes (input)
=A0(loop for sub on (cdr (split-string input "\"")) by (fun= ction cddr) collect (car sub)))

(parts-in-double-quotes "Lorem ipsum dolor sit amet, \"consectetu= r\" adipiscing elit. Donec \"suscipit justo\" sit amet sem b= ibendum \"sit amet\" porttitor mi pretium.")
--> ("consectetur" "suscipit justo" "sit amet&q= uot;)


--
__Pascal Bourguignon__ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 http://www.informatimago.co= m/

--0016e6d77eac037391047d07abc7--