remove the last two spaces from a string

Arsha

    If the length of my string is 30. I got to remove the last 2 spaces from the string .

    If the length of my string is 29.I got to remove the last space from the string.

     

     

    Eg. COADC Cathy & Ralph Ward Jr 73                                                                                                                                            

    should be COADC Cathy & Ralph WardJr73 

    and not COADCCathy&RalphWardJr73

     

     

    Tried trim() ,instr, substr and replace() spaces but did not work out. is there any other function?

      • 1. Re: remove the last two spaces from a string
        CDuf

        If when you say last 2 spaces you really mean spaces, you could try looking at:

         

        TRIM(TRAILING '1' FROM 'Test1');  //returns 'Test' and replace 1 with ' '  or the RTRIM('123000', '0'); //returns '123' and replace the '0' with ' '

         

        See SuiteAnswer ID: 21503

         

        RTRIM: Removes all specified characters from the right side of a string

        If 'set' parameter is omitted, the RTRIM function will remove all trailing spaces on the right from 'char'.

         

        Syntax:

         

        RTRIM(char [, set ])

         

        Examples:

         

        RTRIM('test  '); //returns 'test'

        RTRIM('test  ', ' '); //returns 'test'

        RTRIM('123000', '0'); //returns '123'

        RTRIM('Test0387', '0123456789');  //returns 'Test'

         

        Note: While using in Formula(Text) for searches, omit the semicolon(;) at the end of the statement.

         

        Just a thought.

        • 2. Re: remove the last two spaces from a string
          Arsha

          this would remove only from the right end.

          I require a solution that removes last 2 spaces from a string. space can be anywhere in the middle or between 2 words.