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

后端 未结 2 2013
粉色の甜心
粉色の甜心 2020-12-30 07:00

i\'ve been trying for some time now to get this working, but i can\'t find a solution to this task myself - ok, i\'m very new to regex-use but quite interested to learn, hop

相关标签:
2条回答
  • 2020-12-30 07:41

    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.

    enter image description here

    Scenario 2: concatenate tags on each line

    You can use this regex:

    (.+?)\[
    

    Working demo

    enter image description here

    0 讨论(0)
  • 2020-12-30 07:56

    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)
    
    0 讨论(0)
提交回复
热议问题