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: Re: Regex to match lines with a specific number of words Date: Sun, 24 Apr 2022 16:31:56 +0200 Message-ID: <87ee1mo8cu.fsf@fastmail.fm> References: <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="4732"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.10; emacs 28.1.50 Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 24 16:38:18 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 1nidNQ-00011C-E7 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Apr 2022 16:38:18 +0200 Original-Received: from localhost ([::1]:57548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nidNP-00028T-3m for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 24 Apr 2022 10:38:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nidMu-00028K-Re for help-gnu-emacs@gnu.org; Sun, 24 Apr 2022 10:37:44 -0400 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:39819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nidMt-00065a-0e for help-gnu-emacs@gnu.org; Sun, 24 Apr 2022 10:37:44 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0F5363201F85; Sun, 24 Apr 2022 10:37:40 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Sun, 24 Apr 2022 10:37:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1650811060; x=1650897460; bh=v8aqNpQBhR jERbvVkZacp+u8F+4cjMmTlhBK8raCEDY=; b=rWK+0zGgpTj4zONIPwI1kGwnzI fXzuI893vTntSeFxUhbX72R+HbCWVdsSceqoPfx3B3NrUpAdOJirc7EWSRIi9rZa MMeEZ7uMOiGP1FYELAZ5Nt47QF+uMqWEYPZRc9oP4zPF0TzUOXTxu6sJWDGGcNlc drcE5+gx6A/dY8BDQfNwRPlX49a4yjorJk9YvoGymwtSP01tuXOotjs4fdnNP7HQ wbu4VyYaI5sz2PQ3SmFNRiFQtDZdj0Ntk9hh4gbS8FNYu43Ct86CgKh1B+sUQOaV 2cOxuPoZf9Tfyga5bpQGcqnjmHtlt7PBDyEFUA7UT1F/PsuLTrhEA2KXFUlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :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=1650811060; x= 1650897460; bh=v8aqNpQBhRjERbvVkZacp+u8F+4cjMmTlhBK8raCEDY=; b=g 1K9U98ozyPcxKiNoZXLDS1jp+hHaKQdEyqRrrqDLoQRzmcFYAwH5d+A6a2m/6Sdu YLPHE6eevbT8IbdU9/eMgl+27TuKNIlZkoEtm/HuGAEOCMbGmqT7vtSIpA6HixYi T63tWYq73WCDfrA020X7mdpoJvR47rjSRsDEhBm4fDiKKs2h5JXLPBdjO7Xn9aOg VR9eu47OUSrZXe7NcxlhbHCQYKd7ixYqgTl436pgc6aIeujvCaPKpr8aUGC1bjt3 4qWKCuBcabuXYCJetXiOQyiNb7cmjgMDmTd3IZ5VvCTItBir5Pq/bS9heY0HyZHM 556ZapyGvUgOB/W/89rnQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrtdelgdektdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvfevufffjgfkgggtsehttdertddtredtnecuhfhrohhmpeflohhoshht ucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhmqe enucggtffrrghtthgvrhhnpefgiefhuddtteeljeehveekjedtffeuheffhffffeetieet feehtdektdeitdekffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehjohhoshhtkhhrvghmvghrshesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 24 Apr 2022 10:37:39 -0400 (EDT) In-reply-to: Received-SPF: pass client-ip=64.147.123.25; envelope-from=joostkremers@fastmail.fm; helo=wout2-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:137011 Archived-At: On Sat, Apr 23 2022, Stefan Monnier via Users list for the GNU Emacs text editor wrote: >>> \([^[:space:]]+[[:space:]]+\)\{30,\} > > I don't think yo want to match more than 30 times: as soon as you have > 30 repetitions you know what to do. True. I modelled it on a regex for SublimeText, which, however, was used in a search and replace operation (where the replacement string was empty), so matching more than 30 times was necessary. But for flush-lines it's not. [...] > Personally, I'd go with something like: > > ^\([^\n\t ]+[\t ]+\)\{30\} Thanks, I'll try that and see if it gives any speed advantages. -- Joost Kremers Life has its moments