I want a regular expression pattern that will match with the end of a string.
I\'m implementing a stemming algorithm that will remove suffixes of a word.
E.g. for
You need to match "s", but only if it is the last character in a word. This is achieved with the boundary assertion $:
input.replaceAll("s$", " ");
If you enhance the regular expression, you can replace multiple suffixes with one call to replaceAll:
input.replaceAll("(ed|s)$", " ");