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
Regex: Problem Replace by: $1\L$2 (Capitalize words)
- DigitalVolcano
- Site Admin
- Posts: 1863
- Joined: Thu Jun 09, 2011 10:04 am
Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)
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.
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)
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?
Can this be added to the wishlist for v4, please?
- DigitalVolcano
- Site Admin
- Posts: 1863
- Joined: Thu Jun 09, 2011 10:04 am
Re: Regex: Problem Replace by: $1\L$2 (Capitalize words)
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)
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.
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.