Friday, February 22, 2019

Oracle: trim, ltrim, and rtrim functions; remove spaces and chars from ends of a string

ltrim: trims a string from the left end.
rtrim: trims a string from the right end.
trim: trims a string from both ends.

By default, they trim the empty spaces away from the ends if you don't specify any particular characters to trim.

For example, you have a string: abcdedcba

      select trim('   abcdedcba ') as st from dual;    or
      select ltrim('   abcdedcba') as st from dual;    or
      select rtrim('abcdedcba   ') as st from dual;    or

       returns :
ST
---------
abcdedcba

To remove the left 'a' of the string:

          select ltrim('abcdedcba', 'a') from dual;

To remove the left 'abc' from the string:

          select ltrim('abcdedcba', 'abc') from dual;
          select ltrim('abcdedcba', 'cba') from dual;
          select ltrim('abcdedcba', 'bca') from dual;

To remove the right 'a' from the string:

          select rtrim('abcdedcba', 'a') from dual;

To remove the right 'ba' from the string:

             select rtrim('abcdedcba', 'ab') from dual;
             select rtrim('abcdedcba', 'ba') from dual;

To remove the 'a' from both ends:

           select trim('abcdedcba', 'a') from dual;

To remove the 'ab' from the left and the 'ba' from the right end:

           select trim('abcdedcba', 'ab') from dual;
           select trim('abcdedcba', 'ba') from dual;

 -----------------------------------------------------------------------------------------------------------------
Watch the blessing and loving online channel: SupremeMasterTV live




If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book for free here.

 
          

No comments:

Post a Comment