Notepad++ and regex: how to UPPERCASE specific part of a string / find / replace

本秂侑毒 提交于 2019-11-30 06:59:48

For part 1 you can use

Find:  ^(.*?)(?=\()
Replace \U\1

Make sure regex is selected

for part 2

Find: ^(.*?)(\(.*?\))
Replace:%htmltag%\1%/htmltag%\2

which takes

WORD1 WORD2 WORD3 (some words in brackets)
WORD1 (some words in brackets)
WORD1, WORD2 (some words in brackets)

and converts it to

%htmltag%WORD1 WORD2 WORD3 %/htmltag%(some words in brackets)
%htmltag%WORD1 %/htmltag%(some words in brackets)
%htmltag%WORD1, WORD2 %/htmltag%(some words in brackets)

Scenario 1: generate uppercase for matches on Notepad++

You can use a regex like this:

\(.*?\)|(\w+)

Working demo

Then on your Find/Replace dialog you can put \U\1 on Replace with. So, if you go over Find Next you can replace the string to generate the uppercase output.

Scenario 2: concatenate tags on each line

You can use this regex:

(.+?)\[

Working demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!