Bruteforce implementation of string matching in Pascal