Mass replace in multiple files - part is same everywhere, part is different in every file



  • Hello. Can anyone help me? I wish to mass replace strings, that have some “standard” characters, that are same in multiple files, and some specific characters, that are only in 1 file.

    So i wish to change:

    SOME_COMMON_CONTENT_BEGINNING:abcdef123:SOME_COMMON_CONTENT_end
    SOME_COMMON_CONTENT_BEGINNING:abcdef456:SOME_COMMON_CONTENT_end
    SOME_COMMON_CONTENT_BEGINNING:abcdef789:SOME_COMMON_CONTENT_end

    TO:

    SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end
    SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end
    SOME_COMMON_CONTENT_BEGINNING:anything:SOME_COMMON_CONTENT_end

    how can i do it? using current notepad ++. Many many thanks :)



  • also, all the files are looong. so i dont want to do the change to the end of the file, just to the end of the line.

    so a file looks like:

    lorem ipsum1
    lorem ipsum2
    SOME_COMMON_CONTENT_BEGINNING:abcdef456:SOME_COMMON_CONTENT_end
    lorem ipsum3
    lorem ipsum4

    NOW I HAVE A SOLUTION:

    replace this: XXXXXXXXXX.*YYYYYYYYYY
    with whatever you want :) So one dot and one * is enough. Working in the middle of the files as well…



  • @Stanislav-Elvenisko-Hoferek
    I’m not sure what your second post was meant to say. Did you even try that?

    My suggestion is start with 1 file opened in NPP and test what I provide. If it works the same method can also work on a bunch of files using the other tab of the Replace function called “Find in Files”.
    So
    Find What:(SOME_COMMON_CONTENT_BEGINNING:)(.+?)(:SOME_COMMON_CONTENT_end)
    Replace With:\1anything\3
    This is using your terminology. Up to you to replace the strings SOME_COMMON_CONTENT_BEGINNING:
    anything and
    :SOME_COMMON_CONTENT_end
    with what your actual data is. Note I did bracket the text we will replace (.+?), this is not necessary, but it won’t change the result.

    Terry