help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to grep for a string spanning multiple lines?


From: Emanuel Berg
Subject: Re: How to grep for a string spanning multiple lines?
Date: Sun, 27 Nov 2022 14:48:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Marcin Borkowski wrote:

>>> 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.
>>
>> (re-search-forward ";; Hello my friend\n;; stay a while, and listen")
>>
>> ;; Hello my friend
>> ;; stay a while, and listen
>
> Well, that's obviously cheating. The real problem is how to
> search when you have no idea where you have spaces and where
> you have newlines...

Okay, I didn't understand ... you want to search for something
you or someone else said (wrote), but you only remember the
words, not punctuation, whitespace etc?

It can be done with regular expressions of course, but ...
I wonder if it isn't better to have some "inexact" search
algorithm which quantifies the proximity or score of each
inexact hit in a set of results, so that - if I just make
things up for a possible search for "Hello my friend" in
a body of text where it doesn't quite exist - it could produce
fallout such as

  results           score
  -----------------------
  Hello my Fräulein   89%
  Hello MySQL         28%
  Go to Helvetia       3%

Because the advantage would then also be that even the words
wouldn't have to be exact!

Interesting, I'd like that myself very much!

Do we have that?

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]