Community
    • Login

    Adding " at the beginning and end of every line

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 92.7k 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.
    • W CW
      W C
      last edited by

      I was given the following info and it worked until yesterday but does not work today. This is VERY strange. Instead of adding just a double quote at the beginning or end, it replaces the first or last character with the & symbol.

      For example, you can add a quote at the end of every line:
      Edit > Find & Replace
      Search for: .$
      Replace with: &"

      Options/Regular expressions: ON

      Click Replace All

      And, similarly, at the beginning:
      Search for: ^.
      Replace with: "&

      I have restarted the program and reloaded the document with no success. What is wrong now? I have tried it over and over again and get the same result.

      Thanks.

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • gerdb42G
        gerdb42
        last edited by

        I think you need to write $&" and "$& for replacement. You may want to use [^"] instead of . to skip lines already beginning/ending with ". Use [^"\r\n] to also skip empty lines.

        1 Reply Last reply Reply Quote 0
        • Claudia FrankC
          Claudia Frank @W C
          last edited by

          Hello @W-C

          when having

          Search for: $
          Replace with: "
          

          and

          Search for: ^
          Replace with: "
          

          then it should have worked but not with the dot char added and with the restriction gerdb42 mentioned.

          You can also use a single regex, something like

          Search for: ^(.+)$
          Replace with: "\1"
          

          Search for explained:
          ^ = from the beginning of the line
          (.+) = looking for atleast one but as much as possible chars and return the match until
          $ = end of line is reached

          Replace with explained:
          " = insert a double quote followed by the
          \1 = matched result and
          " = add an additional double quote

          Cheers
          Claudia

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