From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: "Tassilo Horn" Newsgroups: gmane.emacs.help Subject: Re: count matches in string, not region? Date: Wed, 26 Feb 2020 20:49:51 +0100 Message-ID: <009f6fb0-8191-48f5-8541-52d95cfecd83@beta.fastmail.com> References: <87a756gedt.fsf@ebih.ebihd> <87pne1g92p.fsf@ebih.ebihd> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="44080"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.1.7-947-gbed3ff6-fmstable-20200220v2 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 26 20:50:35 2020 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 1j72hW-000BLW-RL for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Feb 2020 20:50:34 +0100 Original-Received: from localhost ([::1]:49198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j72hV-0007HQ-T2 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Feb 2020 14:50:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33354) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j72hC-0007HA-34 for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 14:50:15 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1j72hB-0003Cn-Vo for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 14:50:14 -0500 Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:37831) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1j72hA-0000Oo-Sx for help-gnu-emacs@gnu.org; Wed, 26 Feb 2020 14:50:13 -0500 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 684B8220F8 for ; Wed, 26 Feb 2020 14:50:12 -0500 (EST) Original-Received: from imap34 ([10.202.2.84]) by compute7.internal (MEProxy); Wed, 26 Feb 2020 14:50:12 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrleeggddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderredtnecuhfhrohhmpedfvfgrshhsihhlohcujfhorhhnfdcuoehtshguhhesghhn uhdrohhrgheqnecuffhomhgrihhnpehuuhdrshgvpdgurghtrghsfigrmhhprdhorhhgne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhr nhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeife ehvdelkedqthhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 290021460061; Wed, 26 Feb 2020 14:50:12 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <87pne1g92p.fsf@ebih.ebihd> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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:122484 Archived-At: Another way would be (string-match-p "^[[:digit:]]\\{13\\}$" isbn) which returns non-nil iff isbn is a string of exactly thirteen digits. Bye, Tassilo Am Mi, 26. Feb 2020, um 07:24, schrieb Emanuel Berg via Users list for the GNU Emacs text editor: > > Anyway as you see the 4th line doesn't look > > good, instead of moving the point one would > > like to invoke the/a count function with the > > already-fetched isbn-as argument. > > > > So is there a count-matches-in-string or > > something to that extent anywhere, that you > > are aware of? > > Problem solved with `replace-regexp-in-string'. > > Can still be useful to count matches in > a string, I guess... > > Yank it in a temporary buffer and then use > region there is perhaps a poor man's solution... > > (defun check-isbn-at-point () > "Compute and echo the check digit from the ISBN at point." > (interactive) > (let*((isbn-string (thing-at-point 'symbol t)) > (digits-only (replace-regexp-in-string "[^0-9]" "" isbn-string)) > (num-digits (length digits-only)) > (check-digit (if (> num-digits 10) > (checksum-isbn-13 digits-only) > (checksum-isbn-10 digits-only) ))) > (message "check digit: %s" check-digit) > )) > (defalias 'ciap #'check-isbn-at-point) > > -- > underground experts united > http://user.it.uu.se/~embe8573 > https://dataswamp.org/~incal > > > >