diff --git a/main/cli.c b/main/cli.c
index 55225ed43b0f7e9466edaacb9fe2c0ffefd95345..85f4473ee5948d96a5dfb68d4100d0098f11cf0b 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1879,20 +1879,30 @@ static int word_match(const char *cmd, const char *cli_word)
 		return -1;
 	if (!strchr(cli_rsvd, cli_word[0])) /* normal match */
 		return (strcasecmp(cmd, cli_word) == 0) ? 1 : -1;
-	/* regexp match, takes [foo|bar] or {foo|bar} */
 	l = strlen(cmd);
 	/* wildcard match - will extend in the future */
 	if (l > 0 && cli_word[0] == '%') {
 		return 1;	/* wildcard */
 	}
+
+	/* Start a search for the command entered against the cli word in question */
 	pos = strcasestr(cli_word, cmd);
-	if (pos == NULL) /* not found, say ok if optional */
-		return cli_word[0] == '[' ? 0 : -1;
-	if (pos == cli_word)	/* no valid match at the beginning */
-		return -1;
-	if (strchr(cli_rsvd, pos[-1]) && strchr(cli_rsvd, pos[l]))
-		return 1;	/* valid match */
-	return -1;	/* not found */
+	while (pos) {
+
+		/*
+		 *Check if the word matched with is surrounded by reserved characters on both sides
+		 * and isn't at the beginning of the cli_word since that would make it check in a location we shouldn't know about.
+		 * If it is surrounded by reserved chars and isn't at the beginning, it's a match.
+		 */
+		if (pos != cli_word && strchr(cli_rsvd, pos[-1]) && strchr(cli_rsvd, pos[l])) {
+			return 1;	/* valid match */
+		}
+
+		/* Ok, that one didn't match, strcasestr to the next appearance of the command and start over.*/
+		pos = strcasestr(pos + 1, cmd);
+	}
+	/* If no matches were found over the course of the while loop, we hit the end of the string. It's a mismatch. */
+	return -1;
 }
 
 /*! \brief if word is a valid prefix for token, returns the pos-th