Hi all,
When using find and replace with regex, is it possible to replace text with capitalized letters of the matching text?
Thanks!
Hi all,
When using find and replace with regex, is it possible to replace text with capitalized letters of the matching text?
Thanks!
There might be a way via regex but I don’t know it off the top of my head.
However if you already have the text selected, you can convert to uppercase via the menu Edit > Convert Case > Upper Case
(also available from the Command Palette).
A \U
in front of a capture in the regex replacement will replace the text with an upper case version, and \L
will lower case it.
For example, if you search Lorem
and replace with \U$0
, that would indicate that the whole of the matched text (represented by $0
) should be replaced uppercase.
You can also do that with more regular captures, such as \bl(\w+)
and a replacement of L\U$1
if you wanted to find all words starting with a lower case l
and replace them with all uppercase equivalents, etc.