Community
    • Login

    Adding " at the beginning and end of every line

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 3 Posters 104.1k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors