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