Need help with Replacing lines

  • I have about 100k lines like these
    And i want to change each line to only this
    can someone help me how to do that?

  • Hello @ilya-levadny and All,

    Actually, you want to delete all characters located after the second colon character, included, of any line

    Indeed, not difficult with regular expressions !

    • Open the Replace dialog ( Ctrl + H )

    • SEARCH (?-s)^(.+?:.+?):.+

    • REPLACE \1

    • Select the Regular expression search mode

    • Check, preferably, the Wrap around option

    • Click, once on the Replace All button or several times on the Replace button

    An other formulation would be :

    • SEACRH (?-s)^.+?:.+?\K:.+


    This time, due to the \K syntax you must use the Replace All button, exclusively

    Notes :

    • The (?-s) in-line modifier means that dot ( . ) matches any single standard character, only

    • The .+?: part looks for the shortest non-null range of characters till a colon ( : )

    • The part between parentheses ( .+?:.+? ) is stored as group 1, which must be rewritten, during the replacement phase

    • At the end, the .+ syntax represents the rest of the line, after the second colon char, included, of the current line

    • In the second version, after matching the implicit group 1, the \K syntax resets the regex engine, so the final overall match is the part :.+ which corresponds to the second colon char with all the subsequent chars of current line, which are deleted as the replacement zone is empty

    Best Regards,


Log in to reply