how to find the No. of matches if i use patterns and matcher in java?
<p>i have the following code</p>

<pre><code>    Pattern keyPattern = Pattern.compile(key);
    Matcher matcher = keyPattern.matcher(str);
    return matcher.replaceAll(value);
</code></pre>

<p>this will replaces the key in the str with value;
but i want to know how many instances of key's has been replaced with value.
so how to know that?</p>
