From: Arthur Miller <arthur.miller@live.com>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: How to grep for a string spanning multiple lines?
Date: Sat, 26 Nov 2022 11:57:43 +0100 [thread overview]
Message-ID: <AM9PR09MB4977BE8B10FA964C6D87F0E396119@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <8735a6cj2k.fsf@mbork.pl> (Marcin Borkowski's message of "Sat, 26 Nov 2022 07:42:59 +0100")
Marcin Borkowski <mbork@mbork.pl> writes:
> Hi all,
>
> assume I have a file (probably an Org mode one) with some stuff
> I archived from the 'net. (I'm going to start to sue
> youtube-sub-extractor.el.) Here is my problem: assume I remember that
> someone in some video said something, and I want to find that part.
> However, it turns out that it is split between two (or more) lines.
>
> Traditional `grep' is not helpful in this situation. Neither is
> isearch, nor swiper. One idea would be to convert the subtitles to one
> long line (which is an option), but are there any other ways to search
> for a string spanning more than one line (and not knowing which words
> are separated by a space and which ones by a newline)?
>
> Both Emacs-y and shell-y tools would be appreciated.
>
> TIA,
If your plans are to use regex search & friends in Emacs Lisp, then
matching over multiple lines can be a bit tricky. Out of the box,
without trixing with syntax tables (which I am not familiar with), ".*"
will match only to the end of the line. You can use ".*\\(\n.*\\)*".
I have learned it from the Wiki page:
https://www.emacswiki.org/emacs/MultilineRegexp . I don't know if you
are aware of it already or not, hope it helps.
next prev parent reply other threads:[~2022-11-26 10:57 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-26 6:42 How to grep for a string spanning multiple lines? Marcin Borkowski
2022-11-26 8:27 ` Jean Louis
2022-11-26 8:36 ` tomas
2022-11-26 8:43 ` Jean Louis
2022-11-26 8:59 ` Eli Zaretskii
2022-11-26 9:06 ` Jean Louis
2022-11-27 7:31 ` Michael Heerdegen
2022-11-27 7:44 ` Jean Louis
2022-11-27 12:04 ` Michael Heerdegen
2022-11-27 18:25 ` Jean Louis
2022-11-26 10:57 ` Arthur Miller [this message]
2022-11-26 14:55 ` Emanuel Berg
2022-11-27 6:54 ` Marcin Borkowski
2022-11-27 7:26 ` Jean Louis
2022-11-27 13:48 ` Emanuel Berg
2022-11-27 18:10 ` tomas
2022-11-27 19:04 ` Emanuel Berg
2022-11-27 19:46 ` [External] : " Drew Adams
2022-11-28 5:07 ` tomas
2022-11-28 6:17 ` Drew Adams
2022-11-29 2:00 ` Emanuel Berg
2022-11-28 21:05 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-11-28 21:12 ` Emanuel Berg
2022-11-28 21:17 ` Emanuel Berg
2022-12-04 21:55 ` Rudolf Adamkovič
2022-12-05 23:06 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM9PR09MB4977BE8B10FA964C6D87F0E396119@AM9PR09MB4977.eurprd09.prod.outlook.com \
--to=arthur.miller@live.com \
--cc=help-gnu-emacs@gnu.org \
--cc=mbork@mbork.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).