From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Regex to match lines with a specific number of words Date: Sat, 23 Apr 2022 21:44:21 +0200 Message-ID: <87czh7ttzt.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18544"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 28.1.50 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 23 22:39:57 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1niMXs-0004ZC-0L for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 22:39:56 +0200 Original-Received: from localhost ([::1]:38532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niMXq-00050w-Ih for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 16:39:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niMXA-00050o-NE for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 16:39:12 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:37115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niMX8-00036M-P1 for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 16:39:12 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2A9513200C17 for ; Sat, 23 Apr 2022 16:39:07 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 23 Apr 2022 16:39:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm1; t= 1650746346; x=1650832746; bh=clXMaIrklDQYHO8qhfnNZ11Do1za5ydQlUM r4dXmLFs=; b=wJOqYJZIcVnmsx1RbcPx6feoHGVVS5ciRyv/Hq/CKXV+Bgjux9K P73kiewanp8h/5MrWvZDsPpWHp5okc6yBSIeoczjtZihHxzSlASPZIwFFfR7mg7/ sSMUOcIpLXVIlzC8USVxAvTEY5mEepGAZoqe5VZ9nMO5AX6Oaryj+3fywiHpm5Jv gpS15pM3qXJDIx/O85Sx6XtISh/xqzRuhQSZualacdpPNkbBmndwCGiZ8/LzPkhf bx5v25eXUgHyYgBxWk0uBj3oUcWpKiZ/Vm/8fTIYUwpCjzWjD4icMEcK/xKZQP6w EMPNlBn5Y5G2v7Q4bJyGUSZF7ltlLRP56Sw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1650746346; x=1650832746; bh=clXMaIrklDQYH O8qhfnNZ11Do1za5ydQlUMr4dXmLFs=; b=M6SlLQO3gAsPGjpy7Al8BHqVei+Zo xhybYUQ0cxhHAXseMzJPDg5jj1MqXTbs9tl3uVoHKv/iNb5Q5wUBVUUgHTzbdAww RpGk94Nr795rS527xE4TszXXl0a8Fa6cOWRoaQgyyZ0j81Z5/sdZey5ru6nlnvq2 0IivC/hM1ERD8GjXBd9nEgX2s+IDLSUTrJ3vTlrvBkQJkgzmUWT6+ONGz25wQPuO +8GcLlFYx4kTFm/0zNv5NAKiWmlqlMmbNs87wgr5NN0q+AXF9TFkilbxAmo6RipW gamldsQ39FAFG3y8FJiyQN36UxcLP6ThlivYTBIskmkP+pa0sMGiQ0VCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrtdeigdduheefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegfhffvufffkfggtgesthdtredttd ertdenucfhrhhomheplfhoohhsthcumfhrvghmvghrshcuoehjohhoshhtkhhrvghmvghr shesfhgrshhtmhgrihhlrdhfmheqnecuggftrfgrthhtvghrnhepudeufedttefgleekhe eihfegtdelvdeutddvvedukedtieffiefhgfdvhfdtudefnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhoohhsthhkrhgvmhgvrhhssehfrg hsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 23 Apr 2022 16:39:05 -0400 (EDT) Received-SPF: pass client-ip=64.147.123.21; envelope-from=joostkremers@fastmail.fm; helo=wout5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137002 Archived-At: 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