Page 1 of 1

Regex: Problem Replace by: $1\L$2 (Capitalize words)

Posted: Fri Mar 03, 2017 7:36 pm
by me_suzy
hello. I have this regex that doesn't work:

Lowercase letters within words (e.g. LowerCASe => Lowercase)
Find: (\w)([A-Z]+)
Replace: $1\L$2

The problem is at replace. $1\L$2 does't work. Ii replace all the words with \L

Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)

Posted: Thu Mar 09, 2017 11:00 am
by DigitalVolcano
It doesn't support case switches in the replace text.

If you look to the right of the replace box there are options in the drop-down list to replace with upper, lower and title case if this helps.

Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)

Posted: Fri Mar 17, 2023 9:38 am
by ebulerdo
Some years have passed since this was posted. I am exactly in the same situation as the OP. It would be very useful to support \L$ or whatever code to change case in replacements.

Can this be added to the wishlist for v4, please?

Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)

Posted: Wed Apr 05, 2023 10:11 am
by DigitalVolcano
Isn't the case replace setting suitable (to the right of the replace box), or do you need more control over the individual capture groups?

Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)

Posted: Wed Apr 05, 2023 11:20 pm
by ebulerdo
The case replace setting is helpful when you want to apply that change to the whole replacement string. It would be very useful to be able to change case of the capture group only, though. In the regex flavor I use this is done with \u1 or \l1. It seems in the flavor the OP uses it's L$1. Any way would be ok for me.

In this particular case I am working on, I need to reuse some file extensions (jpg, pdf, tif) in uppercase (JPG, PDF, TIF) in a different part of the string. Right now I'm working around it by using a mark before the text (¬jpg, ¬pdf) then running a separate replacement for every extension (replace ¬jpg with JPG). But it would be much more concise and agile if it could all be handled with only one replacement.

Thanks for considering this.