There is no direct equivalent, however if you want to strip trailing whitespace you can use:
"string".replaceAll("\\s+$", "");
\s
is the regular expression character set "whitespace", if you only care about stripping trailing spaces, you can replace it with the space character. If you want to use the more general form of trimEnd(), that is to remove an arbitrary set of trailing characters then you need to modify it slightly to use:
"string".replaceAll("[" + characters + "]+$", "");
Do be aware that the first argument is a generic regex, and so if one of your characters
is the ]
then this needs to be the first character in your list. For a full description of the java regex patterns, look at the javadoc.
Should you ever need to implement the trimstart() method from .net, it is almost the same, but would look like this:
"string".replaceAll("^[" + characters + "]+", "");