[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with regexp nested groups
From: |
Phil Carmody |
Subject: |
Re: Problem with regexp nested groups |
Date: |
Sat, 10 May 2008 22:54:43 +0300 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Marc Tfardy <m-t-o___CUT__IT@web.de> writes:
> 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.
...
> "\\(DATA=\"\\(.*?\.mp3\\)\"\\|OBJ('\\(.*?\.mp3\\)')\\)" nil t)
How about grouping /DATA="/ or /OBJ('/ as match 1, then capture
the filename as 2, and end with /.mp3"/ or /.mp3'/ as match 3?
That would match malformed lines such as
DATA="foo.mp3'
but if that's a problem you can capture the quotes too and
fix them in post-production.
Phil
--
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration