renaming properties via loop

I would like to rename most of the property names in my datasets. If a space is identified in the property name, then a rename function will be put in action. However, I was not able to find a function where i can remove space that are in the middle of the property name. For example, current property name is "abc def ghi" (there are one space each after c and f), end result of the rename would look like "abcdefghi". Sometime there could be consecutive spaces such as "abc def" (2 spaces after c). The trim function seems to only remove space at the beginning and/or the end or contract multiple spaces into one space. The below codes does not fit the bill. Is there way to remove those spaces in property names? Thank you!

FOR #i IN 1 .. NumProperties() 
LOOP 

If IthPropertyName(#i) RLIKE ' ' THEN
rename( IthPropertyName(#i), trim(IthPropertyName(#i));
 
END IF; 

END LOOP;