all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Problem with regexp nested groups
@ 2008-05-10 15:59 Marc Tfardy
  2008-05-10 19:32 ` Lennart Borgman (gmail)
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Marc Tfardy @ 2008-05-10 15:59 UTC (permalink / raw)
  To: help-gnu-emacs

Hallo,

I have some problem with regexp and I hope someone could help me.


Assume we have following text in a buffer.

-- DATA ----------------------------------------------------------------
<DATA="some/file/sample1.mp3">
<DATA="some/file/sample2.mp3">
blablalba
<DATA="some/file/sample3.wav">
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



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-05-11 11:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-10 15:59 Problem with regexp nested groups Marc Tfardy
2008-05-10 19:32 ` Lennart Borgman (gmail)
2008-05-10 19:54 ` Phil Carmody
2008-05-10 22:31   ` Marc Tfardy
     [not found] ` <mailman.11419.1210447961.18990.help-gnu-emacs@gnu.org>
2008-05-10 22:09   ` Marc Tfardy
2008-05-11  9:14 ` Johan Bockgård
2008-05-11 11:59   ` Marc Tfardy

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.