View Single Post
Old 02-03-2020, 09:19 AM   #3
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,801
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Pippo53s03 View Post
Can you suggest a regular expression for truncating paragraphs longer than 1000 characters? it doesn't matter if blank spaces are included in calculation or not.
thanks!
Hmmm, I'm not sure but maybe this can help you:

Find: (.{999})([^ ]+)(\s)(.)
Replace: \1\2</p>\n\n<p>\4

The above will find any string of 1000 chars and a few chars more until to find an space (because I suppose you won't want to split the paragraph in the middle of a word). But first you must select the text where you want to do the S&R (otherwise the regex will work also in the header of the .xhtml file) or don't select the "wrap" option, set the pointer after the body tag and do the S&R in the current file.

EDIT: If you want to find any string of 1000 chars plus a few more chars until to find a ". " (that would mean the end of a sentence) then use the following:

Find: (.{999})([^ ]+)(\.\s)(.)
Replace: \1\2.</p>\n\n<p>\4

Last edited by RbnJrg; 02-03-2020 at 09:34 AM.
RbnJrg is offline   Reply With Quote