java regex when pattern might not match
<p>How would I go about executing a block of code if the pattern matches or execute another block of code if the pattern does not match?</p>

<pre><code>String input = "abc";

final String mainRegex = "(.*?)(&amp;!|&amp;|==)";

final Matcher matcher = Pattern.compile(mainRegex).matcher(input);
</code></pre>

<p><br />
I have tried </p>

<pre><code>if(matcher1.matches())
{
    execute this block
}

else
{
    execute this block
}
</code></pre>

<p>But it always executes the <code>else</code> block. Even when the input is <code>a&gt;b&amp;!c&lt;d</code>.</p>
