There are lots of ways, not all equivalent. Unicode, for instance, makes the question a lot more complicated, as does locales.

For plain declarative sentences in ASCII, like you are parsing for,

while(<>){ if(/\.\s+([A-Z]+)/){ print "$1 is capitalized\n"; } }
will pick up capitolized initial words for all but the first sentence and sentences starting after a $/ [usu. linebreak]. The first sentence has no preceding period. That also ignores the possibility of text with dialogue, interrogation points, exclamation points, ellipsis, ... There is a CPAN module, Lingua::EN::Sentence, which may be useful to you.

The perl functions uc, lc, ucfirst, and lcfirst are handy for this kind of comparison. Accepting the sentence matching of your example for simplicity,

if ( /\.\s+(\w+)/ and $1 eq ucfirst($1) ) { print "That'un's Ok", $/; }
That re picks the first word after a period and whitespace.

To solve the sentence after linebreak problem, you can either slurp the entire file by local $/=undef; and m//s, or else match terminal periods and keep state in some variable for the next line.

After Compline,
Zaxo


In reply to Re: Regular Expressions by Zaxo
in thread Match non-capitalized words at the beginning of each sentence by WarrenBullockIII

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.