Ending the newsletter at the end of a sentance will require that your script knows what that looks like ie. will the writer always make sure to put a period, question mark etc. at a sentance end and what about abbreviations like the etc. earlier in this paragraph.

You will also have to decide whether you want less than 2000 or just more than 2000 characters so you can end at the end of a sentance. Getting exactly 2000 seems unlikely. If you cut on words, you may be able to get within 20 or so of 2000 characters.

It may be handier to end at a paragraph and have the writer put in a double newline to end paragraphs. This would be easy for a program to find and could break out if the character count is > 2000 and at the end of a paragraph. Or you could have the author to put 2 spaces after sentances and no where else ever. That could be found and split on.

Basically, you have 2 conditions to end. After a 'sentance' and after 2000 characters. For the characters, keep a running count and determining a good breaking point in software is discussed in the preceding paragraphs.


In reply to Re: Removing extra <br> tags by dga
in thread Removing extra <br> tags by huskey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.