all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Regex to match lines with a specific number of words
@ 2022-04-23 19:44 Joost Kremers
  2022-04-23 20:58 ` Thibaut Verron
  2022-04-26 23:55 ` Nick Dokos
  0 siblings, 2 replies; 11+ messages in thread
From: Joost Kremers @ 2022-04-23 19:44 UTC (permalink / raw)
  To: help-gnu-emacs

Hi all,

I've been trying to come up with a regex that will match any line containing at
least 30 words in order to kill them from the buffer (preferably with
`kill-matching-lines`, because I need to move the lines to another buffer.)

Frustratingly enough, I have not been successful. Since "word" here can be
interpreted very broadly, I thought this would be easy. Any sequence of
non-whitespace characters surrounded by whitespace can be considered a "word"
(even if it's a number of some special character such as & or #.) So I did this:

\([^[:space:]]+[[:space:]]+\)

This seems to capture a word (in the above sense) plus any following white space
well enough.

But when I try to modify the regex to only match those lines that repeat this
pattern at least 30 times, it fails:

\([^[:space:]]+[[:space:]]+\)\{30,\}

Passing this to `flush-lines` simply deletes everything in the buffer starting
at point, telling me it "[d]eleted 1 matching line", even though (many) more
lines were deleted. Adding ^ and $ around the regex didn't have any effect.

So what am I doing wrong here? 


-- 
Joost Kremers
Life has its moments



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

end of thread, other threads:[~2022-04-27  7:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-23 19:44 Regex to match lines with a specific number of words Joost Kremers
2022-04-23 20:58 ` Thibaut Verron
2022-04-23 21:20   ` Joost Kremers
2022-04-23 21:46     ` Thibaut Verron
2022-04-23 22:11       ` [External] : " Drew Adams
2022-04-23 22:32         ` Thibaut Verron
2022-04-23 22:21       ` Joost Kremers
2022-04-23 22:46   ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-04-24 14:31     ` Joost Kremers
2022-04-26 23:55 ` Nick Dokos
2022-04-27  7:23   ` Jean Louis

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.