Regex: find capitalized words
<p>How do I find and extract capitalized words of a string with regex?</p>

<p>I would like to:</p>

<ol>
<li>extract the capitalized words of a string, as an array </li>
<li>extract the last capitalized word of a string, as a substring:</li>
</ol>

<p>Both with one regex</p>

<p>If I have this:</p>

<pre><code>var str="This is a STRING of WORDS to search";
</code></pre>

<p>I would like to get this 1:</p>

<pre><code>allCapWords // = ["STRING", "WORDS"]
</code></pre>

<p>and 2:</p>

<pre><code>lastCapWord // = "WORDS"
</code></pre>