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 23:46:14 +0200 Message-ID: References: <87czh7ttzt.fsf@fastmail.fm> <877d7fscug.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="12798"; 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 23:47:01 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 1niNan-00033I-48 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 23:47:01 +0200 Original-Received: from localhost ([::1]:52704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1niNal-0001Ar-QB for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 23 Apr 2022 17:46:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59952) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1niNaG-0001Aj-RT for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 17:46:28 -0400 Original-Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]:45762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1niNaF-0003ny-6E for help-gnu-emacs@gnu.org; Sat, 23 Apr 2022 17:46:28 -0400 Original-Received: by mail-io1-xd2c.google.com with SMTP id z19so7503818iof.12 for ; Sat, 23 Apr 2022 14:46:26 -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=3a966GA6pc0rczv4yAMy/J/VksaPWYOhYuL+6S6QFIE=; b=VOxTyKOBRYEVAAQHAbj1MJ/CgZFTym79etZCFQ9Dslz6N7o8h7Vvc+dRdzv51ydUhZ FUD3PTK96iwBIzX88js5+V6zhYyPTDGWBNHTDOwQi5UGfRZmDbrV4eo/qJeVO4yRsIgK cr+5JncoKtH0wadnvUv0rA8iCoC50I2i2T+W5Cur9byI681gAC0gzpvkHrCLWMs7hHaT fqXvha7oyZb/pc4cAJytwlvus7wMVrrDhGHMp0dDlO41IIsNQBLUH746cyXQBwZOyNIV dGALyGs6Z4M5JUY6HiAQVct3Mssp0XnIXcMv2QIv3pP5KsICJ2hlCmnnmL6erg/y7rb7 a2tw== 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=3a966GA6pc0rczv4yAMy/J/VksaPWYOhYuL+6S6QFIE=; b=l6xC7kh79HLbLNNJEE0O+/iUKFesBpsvldILy1yt2WArUwb0Y8SvDlrvOBzgA63aJ3 MhdlZ3s8BwBpTiloMkjPGgviz4qDYKsmRwtJ3x4S/dsnVTOpN+zRQoUDeU1FM8bxfv8I FZhiJIQPhlvYbmOpG6He3ZOmi++jHVBz78SbpfQM16vuZgJ+stt38LsF70Ti08nAjyl2 VkfHIdZf1LtZTNJ77AFmG+O2KBhVlzx5mBmUFUWQkn8agNdxoXErudTTBFzce0t1lkor PNFjzLiwgp4KFY9G7dpm60XMFcdza3hkNZCgepasFrTHK6BHZZRC3qvipzq6Fiw1ENEW mExA== X-Gm-Message-State: AOAM5313uDDHz8xL11n0CYUo6R3IotmrHmdiWF8VBUtbHNF+a+pdp0sL ldTtPP9wr2dY4Fnutd0vT+bbMJJWzCuCvbWob6Q= X-Google-Smtp-Source: ABdhPJxrt2fJIvHTG1C/MHprjNIRLybGAdf2cRWmgL5jFdSoHFPMYlAxDmejKDaXfDspbIx7eDSDQgBmmq32slHihFM= X-Received: by 2002:a05:6638:3012:b0:317:9a63:ecd3 with SMTP id r18-20020a056638301200b003179a63ecd3mr5129425jak.210.1650750385940; Sat, 23 Apr 2022 14:46:25 -0700 (PDT) In-Reply-To: <877d7fscug.fsf@fastmail.fm> Received-SPF: pass client-ip=2607:f8b0:4864:20::d2c; envelope-from=thibaut.verron@gmail.com; helo=mail-io1-xd2c.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:137005 Archived-At: No problem! The information is in the manual, but hidden behind several layers of redirection. I find the emacswiki page on regular expressions both more synthetic and more informative. Regarding performances, that's a bit strange. Is it better if you add ^ and $ around the expression? Or if you add only ^ and search for exactly 30 repetitions (not 30 or more)? Best wishes, Thibaut Le sam. 23 avr. 2022 =C3=A0 23:34, Joost Kremers = a =C3=A9crit : > > On Sat, Apr 23 2022, Thibaut Verron wrote: > > 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. > > Thanks! I never would have thought of that. (Why isn't this mentioned > explicitly > in the manual?) > > Unfortunately, passing this regexp to `flush-lines` or > `kill-matching-lines` in > a file of close to 65000 lines completely cripples Emacs... One CPU core > runs up > to 100% and Emacs becomes unresponsive. > > Lemme see if a function that goes through the buffer, splits every line o= n > white > space and deletes those that are too long works better. > > Thanks, though, for the quick reply! > > > > -- > Joost Kremers > Life has its moments >