Regular expression change first and last line in all opened files



  • Hello, i just was looking a lot of how to change only first and last line of each opened files in notepad.

    Anyone have meaby regex to change first fine of each file and last one?

    example - first line :

    this is line in my file, all lines are different
    this is line in my file, all lines are different
    this is line in my file, all lines are different
    (…)
    this is line in my file, all lines are different
    this is line in my file, all lines are different

    I want change only first line and last one



  • Ok, i just found working solution how:

    -> remove first and last line in one ore more files in notepad, just using this regex:

    find: `[^\r\n][\r\n]+(.[\r\n]+)[^\r\n]+[\r\n]*’
    change for: \1

    Check regex and matches new line, it works really fine! :)
    Then i just easly can add something in first line with this regex:

    find what: (.*)
    replace with: WHATEVERTEXT\r\n\1

    Also check new line and regex. And the last one action to add something in the last one line of file:

    find: (.*)
    replace with: \1PUT HERE ANY TEXT


Log in to reply