From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.help Subject: Re: Problem with regexp nested groups Date: Sat, 10 May 2008 21:32:33 +0200 Message-ID: <4825F851.6020504@gmail.com> References: <68lv38F2tabu7U1@mid.individual.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1210448007 24745 80.91.229.12 (10 May 2008 19:33:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 10 May 2008 19:33:27 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 10 21:34:04 2008 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 1JuupT-0002ve-Ur for geh-help-gnu-emacs@m.gmane.org; Sat, 10 May 2008 21:34:00 +0200 Original-Received: from localhost ([127.0.0.1]:36443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Juuol-00062k-F7 for geh-help-gnu-emacs@m.gmane.org; Sat, 10 May 2008 15:33:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JuuoB-0005uG-IJ for help-gnu-emacs@gnu.org; Sat, 10 May 2008 15:32:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JuuoA-0005tR-3K for help-gnu-emacs@gnu.org; Sat, 10 May 2008 15:32:39 -0400 Original-Received: from [199.232.76.173] (port=43818 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Juuo9-0005tL-OL for help-gnu-emacs@gnu.org; Sat, 10 May 2008 15:32:37 -0400 Original-Received: from ch-smtp02.sth.basefarm.net ([80.76.149.213]:33590) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Juuo9-0002XZ-6I for help-gnu-emacs@gnu.org; Sat, 10 May 2008 15:32:37 -0400 Original-Received: from c83-254-150-27.bredband.comhem.se ([83.254.150.27]:60225 helo=[127.0.0.1]) by ch-smtp02.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1Juuo6-0000Oq-9B for help-gnu-emacs@gnu.org; Sat, 10 May 2008 21:32:35 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 In-Reply-To: <68lv38F2tabu7U1@mid.individual.net> X-Antivirus: avast! (VPS 080510-0, 2008-05-10), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.150.27 X-Scan-Result: No virus found in message 1Juuo6-0000Oq-9B. X-Scan-Signature: ch-smtp02.sth.basefarm.net 1Juuo6-0000Oq-9B 15336ad10f4e207a3110a07d11ff8c44 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) 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:53887 Archived-At: Marc Tfardy wrote: > Hallo, > > I have some problem with regexp and I hope someone could help me. > > > Assume we have following text in a buffer. > > -- DATA ---------------------------------------------------------------- > > > blablalba > > blabla > OBJ('some/file/sample4.mp3') > OBJ('some/file/sample5.au') > ------------------------------------------------------------------------ > > My goal is to extract some text from the buffer, namely only > portion of text between `DATA="' and `"' or between `OBJ('' and > `''. In both cases text must end with `.mp3' and the left and > right delimeter shoud be ignored. So the right result should look > like this: > > some/file/sample1.mp3 > some/file/sample2.mp3 > some/file/sample4.mp3 > > > I wrote this test function: > > (defun get-data () > (interactive) > (if (re-search-forward > "\\(DATA=\"\\(.*?\.mp3\\)\"\\|OBJ('\\(.*?\.mp3\\)')\\)" nil t) > (message "found: %s" (match-string-no-properties 1)) > (message "failed"))) > > With (match-string-no-properties 1) I get this result: > > found: DATA="some/file/sample1.mp3" > found: DATA="some/file/sample2.mp3" > found: OBJ('some/file/sample4.mp3') > > Not good. Now I replace (match-string-no-properties 1) with > (match-string-no-properties 2) and I get only two results for > both DATA lines: > > found: some/file/sample1.mp3 > found: some/file/sample2.mp3 > found: nil > > The version with (match-string-no-properties 3) returns > only OBJ line: > > found: some/file/sample4.mp3 > found: nil > > > Now the final question: how can I get results like version 2 and > 3 but at ones? I would be grateful for any help > > regards > > Marc Could you perhaps look for both (match-string-no-properties 1) and dito 2?