I have a text file, need to parse the file, and send only 4000 character from that file for further processing. It is possible, I might have more than 4000 characters within a single line. Need to find a way to split the line without breaking the sentence.
Asked
Active
Viewed 112 times
0
-
2What have you tried so far, and what problems are you having exactly? – bassfader Mar 05 '20 at 20:32
-
See [get string truncated to max length](https://codereview.stackexchange.com/questions/101017/get-string-truncated-to-max-length) – Wyck Mar 05 '20 at 20:47
1 Answers
1
Read each character one at a time instead of line by line. When you get to 4000 characters go back to the previous full stop and send that. Then start again until you finish reading all characters. Perhaps if you get to a new line you can also split there.

Michael Ceber
- 2,304
- 1
- 11
- 14
-
Even the salutation will have (.) for eg Mr. ABC,how to avoid them – Senthil_Arun Mar 05 '20 at 22:09
-
oh yeah, I guess use some regex like https://stackoverflow.com/questions/20320719/constructing-regex-pattern-to-match-sentence – Michael Ceber Mar 05 '20 at 22:15