Did you look at the String class? y.contains(x)
should do all or nearly all of what you require.
I just saw you don't need the sequence grouped. No existing function will do what you want but its reasonably easy to write something:
boolean stringContains(String container, String contents) {
// start at the start of both strings
int rpos = 0;
int cpos = 0;
// Scan through till we reach the end of either string
while (rpos<container.length() && cpos<contents.length) {
// If they match advance both counts, otherwise just
// move on through the container
if (container.charAt(rpos) == contents.charAt(cpos)) {
rpos++;
cpos++;
} else {
rpos++;
}
}
// If we reached the end of the contents string then we have a match
return cpos==contents.length;
}