Find minecraft colour codes in string I've written a simple util-method in my spigot plugin to check if a message contains a valid minecraft colour code. A valid minecraft colour code consists of a &amp; followed by a hex digit: 0 to f. Minecraft itself exchanges all &amp; by a §, for reasons that would take too long to explain, it's not possible for the users to send messages to the server directly. Therefore &amp; is generally used as a replacement.
I now have to check at some point, if the message the user sent to the server is coloured, which is the reason this method exists. Here are some quick examples, how it does work:
string value - return value

&quot;Simple String&quot; - false
&quot;Smith&amp;Wesson&quot; - false
&quot;&amp;4This would be red.&quot; - true
&quot;%aGreen &amp;2Darker Green &amp;0 Darkest Green&quot; - true
&quot;&amp;&amp; Omega &amp;&amp;&quot; - false

Here's my code. It does what it's supposed to do, but for some reason it still seems unneccesary clunky to me. Any improvement is welcome :)
    public static boolean isMessageColoured(String message) {
        char[] arr = message.toCharArray();
        for (int i = 0; i &lt; message.length() - 2; i++) {
            if (arr[i] == '&amp;' &amp;&amp; &quot;0123456789abcdef&quot;.contains(Character.toString(arr[i + 1]))) {
                return true;
            }
        }
        return false;
    }
Welcome to Code Review.

Your code returns false for the message &quot;hello&amp;9&quot;, because the method doesn't check the last character. Change the condition in the for-loop to message.length() - 1.

An alternative is to use a regular expression:
public static boolean isMessageColoured(String message) {
    return message.matches(&quot;.*&amp;[a-f0-9].*&quot;);
}

This regular expression matches at least one occurrence of &amp;[a-f0-9] in the message.