unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: [External] : Re: query-replace-regexp on a string with '=' sign
Date: Sun, 18 Sep 2022 17:24:32 +0200	[thread overview]
Message-ID: <87r108zowf.fsf@dataswamp.org> (raw)
In-Reply-To: SJ0PR10MB5488F7758DBBA24283695D4EF3489@SJ0PR10MB5488.namprd10.prod.outlook.com

Drew Adams wrote:

>>> HELLO=WORLD
>>> I want to downcase the part before the equal (=) sign.
>> 
>> (while (re-search-forward "\\(.+\\)\\(=\\)" nil t)...
>
> In most cases you don't want the first group to match any
> `=' chars, in which case it should be something like
> \([^=]+\).

I don't know why mine works, why not everything including the
equals sign _and_ the part after that ends up in the first
group?

But it does work, while replacing the RE with
"\\([^=]+\\)\\(=\\)" doesn't, it downcases the whole thing.

Here, try it yourself:

(while (re-search-forward "\\(.+\\)\\(=\\)" nil t)
  (replace-match
   (concat (downcase (match-string-no-properties 1))
           (match-string-no-properties 2) ) t))

;; We=WE
;; Are=ARE
;; Robots=ROBOTS

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2022-09-18 15:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08  8:10 query-replace-regexp on a string with '=' sign Pankaj Jangid
2022-09-08  9:53 ` Emanuel Berg
2022-09-16 15:15   ` [External] : " Drew Adams
2022-09-18 15:24     ` Emanuel Berg [this message]
2022-09-08 10:49 ` Tassilo Horn
2022-09-08 11:16   ` Emanuel Berg
2022-09-09  4:11   ` Pankaj Jangid
2022-09-09  5:10     ` Tassilo Horn
2022-09-09  7:46       ` Pankaj Jangid
2022-09-09  9:26         ` Tassilo Horn
2022-09-09 12:50           ` Pankaj Jangid
2022-09-09 12:56             ` Tassilo Horn
2022-09-10 16:05               ` Pankaj Jangid

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r108zowf.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).