From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thibaut Verron Newsgroups: gmane.emacs.help Subject: Re: Regex to match lines with a specific number of words Date: Sat, 23 Apr 2022 22:58:48 +0200 Message-ID: References: <87czh7ttzt.fsf@fastmail.fm> Reply-To: thibaut.verron@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32295"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 23 22:59:41 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 1niMqy-0008EO-BD for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 22:59:40 +0200 Original-Received: from localhost ([::1]:41492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niMqw-0007uJ-Uz for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 16:59:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niMqN-0007u6-IR for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 16:59:03 -0400 Original-Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]:38752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niMqL-0005di-R6 for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 16:59:03 -0400 Original-Received: by mail-il1-x136.google.com with SMTP id i8so7085676ila.5 for ; Sat, 23 Apr 2022 13:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=ijEXsGEnXtbMCthwNEwz+uhx0FyS3WzMthZl7SanTt8=; b=ew8lTfLeUR3EEhC0OaMTrLAHUvtTMtxBDZHBet2tD/oWj/jM4u4+hTpIs/avBHzbS/ dM+nTdQfr7Wmh8JjENHDRX96Q7aMbJMezho4CZvuuCBhweTpPxkLWukPb+XLJb6M93sd 9ZHLfG3453iamw8FeojfdgaRrXLcJMwUU/iLWVYuRYLz7PqyZLZDEDUmFKaBPdCmFp2h 4KDxlBvDfk5frR0vX0ROW5cy6g3MUYA8chdRse39OumB8+pIxa6yiAVDjEsazFpjn5oB vTCuWP5Ko9ZrgxzMg9eQckr6egp+bbWNal3Jl1TLNd4m/JXrEhLg/14olCnr3Daqrclg Re1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=ijEXsGEnXtbMCthwNEwz+uhx0FyS3WzMthZl7SanTt8=; b=KtTxGg5J5TqJOIruRIC/y62Rce5q5/Jm46uAH5Nil89HQkmsZbc7l5AInK/0kGCfsd 5ih+9MNKboxN3rkAeIEGGFKvz3/tRpD+oDLLThzCFtzMpTRGkjZQTmSeM3mvcPYQO1UZ kRESiF6lIOfNCEt6TBWbWLE0mJLGyeMunxHdSZuEA1RGBuUL+sQiMBfcoFtDh8HNSgLO ccKCVnn+IRtcAku6VaqW2sqdFmtSW2UbghJNwlXKQtJXflZP4Hv2pKEo8KPfvpkFj+Nt hhlH1MgTxj1VznwV7k5fKiRD6dGR7WFv2PcYDQHB37niVmAHK4znw5rKPebOwt9sIWDp IZyQ== X-Gm-Message-State: AOAM5300iy7DxOTXNS8zK1zFl8+xZTBjedDppJybJhd9ZYusMgqDGs94 S8WsItQZ6mhajpjkspITNcQkkg0kra6Zndfo54c= X-Google-Smtp-Source: ABdhPJxUtm2P4avG8dHUoKAQ2GoLqQw6lTdB2JCwO98ihwVM5ycKb0XpSXijTztcu3TW1EJNW2TouZzXhk0o8cCUWgA= X-Received: by 2002:a92:ddc7:0:b0:2c2:91f5:146b with SMTP id d7-20020a92ddc7000000b002c291f5146bmr4428626ilr.21.1650747540154; Sat, 23 Apr 2022 13:59:00 -0700 (PDT) In-Reply-To: <87czh7ttzt.fsf@fastmail.fm> Received-SPF: pass client-ip=2607:f8b0:4864:20::136; envelope-from=thibaut.verron@gmail.com; helo=mail-il1-x136.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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:137003 Archived-At: Hi, The group [:space:] also matches newline characters. So your search has exactly one match, spanning many lines. You can use [:blank:] instead to match spaces and tabs only, for the separator. It's probably better to keep [^[:space:]] for the first group, you wouldn't want to start matching newlines there. Best wishes, Thibaut Le sam. 23 avr. 2022 =C3=A0 22:39, Joost Kremers = a =C3=A9crit : > 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 b= e > 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 di= d > this: > > \([^[:space:]]+[[:space:]]+\) > > This seems to capture a word (in the above sense) plus any following whit= e > 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 effec= t. > > So what am I doing wrong here? > > > -- > Joost Kremers > Life has its moments > >