>>>>> "P" == Paul Rubel <prubel / bbn.com> writes:

P> # very odd (at least to me) in 1.8.0p3
P> irb(main):005:0> " TEST   .".gsub(/\s*$/, "")
P> => " TEST   . TEST   ." 

 Can you try this

svg% diff -u string.c~ string.c 
--- string.c~   2003-07-20 19:17:52.000000000 +0200
+++ string.c    2003-07-22 10:34:41.000000000 +0200
@@ -1643,6 +1643,7 @@
        bp += len;
        memcpy(bp, RSTRING(val)->ptr, RSTRING(val)->len);
        bp += RSTRING(val)->len;
+       offset = END(0);
        if (BEG(0) == END(0)) {
            /*
             * Always consume at least one character of the input string
@@ -1654,9 +1655,6 @@
            bp += len;
            offset = END(0) + len;
        }
-       else {
-           offset = END(0);
-       }
        cp = RSTRING(str)->ptr + offset;
        if (offset > RSTRING(str)->len) break;
        beg = rb_reg_search(pat, str, offset, 0);
svg%
 
svg% ruby -e 'p " TEST   .".gsub(/\s*$/, "")'
" TEST   ."
svg% 

P> irb(main):002:0> "  string       ".gsub(/\s*$/, 'P')
P> "  stringPP"

 this is normal


Guy Decoux