Community
    • Login

    Regular expression change first and last line in all opened files

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 1 Posters 2.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Patryk PatrykP
      Patryk Patryk
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • Patryk PatrykP
        Patryk Patryk
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors