From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Replace all occurrences of a specific character with another. Date: Sun, 23 Jul 2023 08:36:25 +0800 Message-ID: References: <7a231b60-44e7-57fe-3f9c-99394aae2aa6@magnaspesmeretrix.org> 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="6587"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: PierGianLuca Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 23 02:37:26 2023 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 1qNN6E-0001Y7-FL for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 23 Jul 2023 02:37:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qNN5V-0003h3-QJ; Sat, 22 Jul 2023 20:36:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qNN5U-0003gv-8O for help-gnu-emacs@gnu.org; Sat, 22 Jul 2023 20:36:40 -0400 Original-Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qNN5S-00015t-8d for help-gnu-emacs@gnu.org; Sat, 22 Jul 2023 20:36:40 -0400 Original-Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-ca3cc52ee62so3344195276.0 for ; Sat, 22 Jul 2023 17:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690072597; x=1690677397; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=z53NE3CRwU4hGkvStQuGJcig0DTrWUpPGDBNW5DuBPw=; b=biVWmqeJ3a6MoRHqKGsPHEPZoXsg5Ek6ENgeicL1NuAMlxByHVnSI1BAJtpJd+ddK9 0juvz2t19q1Ai6NMA9/y7N/tM9DIpnt4Q9zgzkLrqC3iyguoo8+PeO0iOD87bvIl3uFJ djt8vKLs6VuDtULUW950fhedQmx2vr//2vCjs7Zq3zcbfK8FQT3d0KEJnwPvMu6Xkv4S UaYSaBUlt6GxDRsRDRWAE3f3FbP8CM9OAx1g069sLPYRTBxvR9pOf0TRhyvoZQOByyKQ H5nr1Du0jVAn3f/BbcLJBMvfl/yH3UvE1dI0ZlnuowzD7agWc36/M0vbU+LXoTytykYW pkYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690072597; x=1690677397; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z53NE3CRwU4hGkvStQuGJcig0DTrWUpPGDBNW5DuBPw=; b=e91zkzmdhJPBVScbY3Ad0w5Y8jPqg0syoATrXukQfRwaiGR21ahcpfDwQrK8fRRVQN hynWtZ2bTf5Ff6aYeXcm/8XTwrkq+rVJGqpsjpVC9K7UQ1TLZNnsLREeeQIr9nvqzEmN ceHIsWmOCDgRHw935hn833aWsuailI92dlqzoAfQ86o2/8Mu9NmQLthWRXI6MH+ZEiBT FOngoxViBVVzVp7grY5X/+7v04JsOD/vE13Ku/3Nf2uMBwlIuPQ23+7eW6MjuMFe5BdD 0+CseeuSucBirbhbGpXsq7RTGox89uLla0Iy8o1NS++mJsUH3pYc35c04SafkwgdCvVh 9TBQ== X-Gm-Message-State: ABy/qLaR2o01Ozd+Z/lSOeZC2lzS4WN+q8a5TpE3YNHOU+Be1pwO4PW/ fME7O8AdsKWbOLieFNXe3TDoAmGgiycQnbbxMX5re/wzUO8= X-Google-Smtp-Source: APBJJlGMB9oQeo2y6PNqghsJIs/batEpy9x5og7QDfH1TvDFP2LlA4JE6B03R6DIDHviIeQgJvy0QHhtm4ySJxxrZ8c= X-Received: by 2002:a81:83c1:0:b0:579:f5e3:ad07 with SMTP id t184-20020a8183c1000000b00579f5e3ad07mr3704044ywf.14.1690072597028; Sat, 22 Jul 2023 17:36:37 -0700 (PDT) In-Reply-To: <7a231b60-44e7-57fe-3f9c-99394aae2aa6@magnaspesmeretrix.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::b34; envelope-from=hongyi.zhao@gmail.com; helo=mail-yb1-xb34.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, 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-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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:144402 Archived-At: On Sat, Jul 22, 2023 at 11:08=E2=80=AFPM PierGianLuca wrote: > > It looks like your character appears surrounded by non-letters in every i= nstance. In this case you could use `query-replace-regexp` replacing > > \ > > with > > n > > The "\<\>" brackets match beginning and end of words: > > https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp- > Backslash.html > > > Your character also seems to appear inside maths expressions only. In thi= s case you could use the function defined in this post: > > http://stackoverflow.com/questions/19845598/emacs-regex-replacing-a-strin= g-inside-a-latex-equation Thank you for the nice tip, but there are several versions of functions suggested there. So, which one is your preferred version? > it's very useful and I use it regularly in LaTeX documents. > > Cheers, > Luca Regards, Zhao > On 230722 16:35, Hongyi Zhao wrote: > > Hi here, > > > > I want to replace all occurrences of a specific character, say, `d`, > > as shown in the attached screenshot, with another character, e.g., > > `n`. Is there any practical way to do this? > > > > Regards, > > Zhao