diff --git a/src/vte.cc b/src/vte.cc
index 9807a1e..8d9136f 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -1582,7 +1582,7 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
                                         g_match_info_free(match_info);
 					return result;
 				}
-				if (ko > rm_eo &&
+				if (ko > rm_eo - 1 &&
 						rm_eo > sblank) {
 					sblank = rm_eo;
 				}
@@ -1608,7 +1608,7 @@ vte_terminal_match_check_internal_gregex(VteTerminal *terminal,
 		*start = sattr + start_blank;
 	}
 	if (end != NULL) {
-		*end = sattr + end_blank;
+		*end = sattr + end_blank - 1;
 	}
 	return NULL;
 }
