[text[i+j].char, '*'].include? pattern[j]  might be better here, if you had to compare it against 4 strings the list of comparisons can get quite long