Search code examples
regexnotepad++

How can I replace single angle brackets with doubles with Notepad++?


I have hundreds of text files under a directory that contain (correctly) some tokens surrounded with << >> like:

Hello, my name is <<myName>> and I am the manager of the <<teamName>> team.

But in some files, some of the tokens are "incorrectly" between < > like:

Hi, this is <myName> from the <<teamName>> team.

How can I use the "Find in Files" feature in Notepad++ to find such < > tokens and replace them with the correct << >> ones?


Solution

  • You can use replace with regex, your regex can be:

    (?<!<)<([a-zA-Z0-9_]+)>(?!>)
    

    and replace with can be:

    <<\1>>
    

    Like this:

    enter image description here