To search within a string in Pascal, use the pos()
method.
It has returns the index of the 1st occurrence of the substring in the string:
pos(originalString, smallString) - looks in originalString smallString
When the substring is not found, the method returns 0:
welcome := 'Hello world! Goodbye world!';
index := pos(welcome, 'wor');
writeln(index); // 7
index := pos(welcome, 'sun');
writeln(index); // 0
Please note: these methods do not look for the number of occurrences, but only determine whether there is such a substring in the string or not.