Fix off-by-one error on * and + patterns