Community
    • Login

    Deleting characters after 30,000 length

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 5 Posters 1.1k 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.
    • Alex VaughanA
      Alex Vaughan
      last edited by

      Hi all

      I need some guidance - I have a file with 350,000 lines of text I need to copy into Excel. However, some of these lines are longer strings than Excel can handle (32,000+).

      Is there a simple way using a regular expression Find and Replace, or other method, to simply cut any text which is longer than 32,000 characters?

      Thank you!

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Alex Vaughan
        last edited by

        @Alex-Vaughan

        There are a few ways. Here’s one:

        Open the Replace dialog by pressing Ctrl+h and then set up the following search parameters:

        Find what box: (?-s)^(.{32000}).+
        Replace with box: \1
        Search mode radiobutton: Regular expression
        Wrap around checkbox: ticked
        . matches newline checkbox: doesn’t matter (because the (?-s) leading off the Find what box contains an s variant)
        Option checkboxes not mentioned are typically not important to the operation, but should in general be unticked.

        Then press the Replace All button.

        Alex VaughanA 1 Reply Last reply Reply Quote 3
        • Alex VaughanA
          Alex Vaughan
          last edited by

          That worked - amazing. Thank you Alan :)

          1 Reply Last reply Reply Quote 2
          • Alex VaughanA
            Alex Vaughan @Alan Kilborn
            last edited by

            @Alan-Kilborn First time on this site, stupid moment - can I recognize your comment as the one that resolved my issue?

            PeterJonesP 1 Reply Last reply Reply Quote 2
            • PeterJonesP
              PeterJones @Alex Vaughan
              last edited by

              @Alex-Vaughan said in Deleting characters after 30,000 length:

              @Alan-Kilborn First time on this site, stupid moment - can I recognize your comment as the one that resolved my issue?

              The upvote that you did on his post
              e5f51143-2e68-4609-ac86-195eef558cfc-image.png
              is the normal way of indicating an answer that is helpful and/or insightful.

              Unlike some forums, there is no system for saying “this is the one true answer” or “this is the best answer”, because more often than not, the “true” or “best” answer draws from many different replies, not just one.

              1 Reply Last reply Reply Quote 2
              • guy038G
                guy038
                last edited by

                Hello, @alex-vaughan, @alan-kilborn, @peterjones and all,

                In this specific case, Alan, instead of storing the 32,000 first characters, of each line, in a group, I think that the \K syntax has a real purpose !

                So, an alternate solution is :

                SEARCH (?-s)^.{32000}\K.+

                REPLACE Leave EMPTY

                Best Regards,

                guy038

                Alan KilbornA 1 Reply Last reply Reply Quote 1
                • Alan KilbornA
                  Alan Kilborn @guy038
                  last edited by

                  @guy038

                  Ha, well, if it can’t temporarily remember ~32KB of data, we’ve got bigger problems. :-)

                  1 Reply Last reply Reply Quote 0
                  • Matt BennettM
                    Matt Bennett
                    last edited by

                    This is simple with the gnu “cut” utility: (linux/cygwin/wsl)

                    cut -c 1-32000 File.txt > NewFile.txt

                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @Matt Bennett
                      last edited by

                      @Matt-Bennett

                      This is true but probably the OP has no idea what gnu/cut/linux/cygwin/wsl are.
                      As this is a Notepad++ forum, please try to confine answers to techniques within Notepad++ unless there truly is no way to do it with Notepad++.

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