Community
    • Login

    How do I create character blocks of specified length?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 2.8k 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.
    • Andrew ScharbarthA
      Andrew Scharbarth
      last edited by

      I was curious if there was a way to get the program to break large continous blocks of text (stuff converted to base 64, for example) into blocks of characters of a specified length so that they can be easily copied and pasted.

      For example:

      /9j/4AAQSkZJRgABAgAAAQABAAD/7QCcUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAIAcAmcAFHd0cks2MHpnR3R5a3pHYVNvNVZrHAIoAGJGQk1EMDEwMDBhYzEwMzAwMDAyYTI1MDAwMDZiNDYwMDAwM2U0OTAwMDA5ZjRiMDAwMGRkNWUwMDAwYmRhYzAwMDBlM2I0MDAwMDgzYmIwMDAwNzhjMTAwMDA4MjYzMDEwMP/iAhxJQ0NfUFJPRklMRQABAQAAAgxsY21zAhAAAG1udHJSR0IgWFlaIAfcAAEAGQADA

      to

      /9j/4 AAQSk ZJRgA BAgAA AQABA AD/7Q CcUGh vdG9z aG9wI DMuMA A4Qkl NBAQA AAAAA IAcAm cAFHd 0cks2 MHpnR 3R5a3 pHYVN vNVZr HAIoA GJGQk 1EMDE wMDBh YzEwM zAwMD AyYTI 1MDAw MDZiN DYwMD AwM2U 0OTAw MDA5Z jRiMD AwMGR kNWUw MDAwY mRhYz AwMDB lM2I0 MDAwM DgzYm IwMDA wNzhj MTAwM DA4Mj YzMDE wMP/i AhxJQ 0NfUF JPRkl MRQAB AQAAA gxsY2 1zAhA AAG1u dHJSR 0IgWF laIAf cAAEA GQADA

      1 Reply Last reply Reply Quote 0
      • MAPJe71M
        MAPJe71
        last edited by

        Use search & replace i.e.

        • Ctrl-H
        • Find what: ([\w/]{5})
        • Replace with: \1
        • Search mode: Regular expression
        • Ctrl-A (Replace All)
        1 Reply Last reply Reply Quote 0
        • MAPJe71M
          MAPJe71
          last edited by

          Sorry, that didn’t work out i.e. trailing space not visible …

          • … as above
          • Replace with: "\1 " i.e. backward-slash + one + space
          • … as above
          1 Reply Last reply Reply Quote 0
          • guy038G
            guy038
            last edited by

            Hello Andrew,

            An other formulation, which separates any text in blocks of five characters long, whatever they are, would be :

            SEARCH .{5}(?=.)

            REPLACE $0\x20

            Notes :

            • The .{5} syntax matches for five consecutive standard characters

            • I added the look-ahead form (?=.) , just to ensure that NO extra-space will be added, at the end of each long-line scan

            • The $0 syntax represents the match of the whole regex, that is to say, any block of five characters

            • And \x20 is, simply, the hexadecimal form of the space character

            Best Regards,

            guy038

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