Data Structures and Algorithms - Navie Search Pattern

Hello All

i have difficulty solving the second half of the navie pattern search code challenge where i’m given instructions on how to replace patterns in text. i would be thankful if someone can help posting the solution code with some illustration

thanks in addvance

hello i still need help on this one appreciate if someone can help