class Ideone
{
public static void main
(String[] args
) {
System.
out.
println(text.
replaceFirst("\\s++$",
"")); }
}
Y2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKQoJewoJCWZpbmFsIFN0cmluZyB0ZXh0ID0gIiAgZm9vICAgIjsKCQlTeXN0ZW0ub3V0LnByaW50bG4odGV4dC5yZXBsYWNlRmlyc3QoIlxccysrJCIsICIiKSk7Cgl9Cn0=