[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [External] : Re: query-replace-regexp on a string with '=' sign
From: |
Emanuel Berg |
Subject: |
Re: [External] : Re: query-replace-regexp on a string with '=' sign |
Date: |
Sun, 18 Sep 2022 17:24:32 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
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
- Re: query-replace-regexp on a string with '=' sign, (continued)
- Re: query-replace-regexp on a string with '=' sign, Pankaj Jangid, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Tassilo Horn, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Pankaj Jangid, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Tassilo Horn, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Pankaj Jangid, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Tassilo Horn, 2022/09/09
- Re: query-replace-regexp on a string with '=' sign, Pankaj Jangid, 2022/09/10
Re: query-replace-regexp on a string with '=' sign, Emanuel Berg, 2022/09/16
Re: query-replace-regexp on a string with '=' sign, Emanuel Berg, 2022/09/16