Like this?
Code:
@init
// Strip whitespace from end of string
function rtrim(x)
local(c, p)
(
p = strlen(x);
while (p >= 1 && ((c = str_getchar(x, p - 1)) == ' ' || c == '\t')) ( p -= 1 );
str_setlen(x, p);
);
#s1 = "String ";
#s2 = "STRING ";
before1 = strlen(#s1);
before2 = strlen(#s2);
#s1 = rtrim(#s1);
#s2 = rtrim(#s2);
after1 = strlen(#s1);
after2 = strlen(#s2);