Deleting characters after 30,000 length
-
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!
-
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 ans
variant)
Option checkboxes not mentioned are typically not important to the operation, but should in general be unticked.Then press the Replace All button.
-
That worked - amazing. Thank you Alan :)
-
@Alan-Kilborn First time on this site, stupid moment - can I recognize your comment as the one that resolved my issue?
-
@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
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.
-
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
-
Ha, well, if it can’t temporarily remember ~32KB of data, we’ve got bigger problems. :-)
-
This is simple with the gnu “cut” utility: (linux/cygwin/wsl)
cut -c 1-32000 File.txt > NewFile.txt
-
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++.