Search code examples
regexreplacenotepad++

How to replace all words that contain a certain string in notepad++


I'm struggling to figure out how to replace full words containing certain strings, i have been searching and trying for a small while but anything i come across either doesn't work or replaces far too much,

to give an example of what i need exactly, if we have a text lets take a part of the lyrics from bones as an example.

My patience is waning
Is this entertaining?
Our patience is waning
Is this entertaining?

i want to be able to replace every word that contains "ing" with something else for example "boop", this should result in,

My patience is boop
Is this boop?
Our patience is boop
Is this boop?

my problem mainly lies in the fact that everything i try only replaces the "ing" or everything infront of it aswell and not only the word that contains it.


Solution

  • If you want to also replace words with ing in the middle of a word, use:

    • Ctrl+H
    • Find what: [a-z]*ing[a-z]*
    • Replace with: boop
    • UNTICK Match case
    • TICK Wrap around
    • SELECT Regular expression
    • Replace all

    Explanation:

    [a-z]*      # 0 or more letters
    ing         # literally
    [a-z]*      # 0 or more letters
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here