Oracle/PLSQL: RTRIM Function-from cyber

Oracle/PLSQL: RTRIM Function

This Oracle tutorial explains how to use the Oracle/PLSQL RTRIM function with syntax and examples.

Description

The Oracle/PLSQL RTRIM function removes all specified characters from the right-hand side of a string.

Syntax

The syntax for the RTRIM function in Oracle/PLSQL is:

RTRIM( string1 [, trim_string ] )

Parameters or Arguments

string1
The string to trim the characters from the right-hand side.
trim_string
Optional. The string that will be removed from the right-hand side of string1. If this parameter is omitted, the RTRIM function will remove all trailing spaces from string1.

Note: See also the LTRIM and TRIM functions.

Applies To

The RTRIM function can be used in the following versions of Oracle/PLSQL:

  • Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i

Example

Let's look at some Oracle RTRIM function examples and explore how to use the RTRIM function in Oracle/PLSQL.

For example:

RTRIM('tech   ')
Result: 'tech'

RTRIM('tech   ', ' ')
Result: 'tech'

RTRIM('123000', '0')
Result: '123'

RTRIM('Tech123123', '123')
Result: 'Tech'

RTRIM('123Tech123', '123')
Result: '123Tech'

RTRIM('Techxyxzyyy', 'xyz')
Result: 'Tech'

RTRIM('Tech6372', '0123456789')
Result: 'Tech'

The RTRIM function may appear to remove patterns, but this is not the case as demonstrated in the following example.

RTRIM('Techxyxxyzyyyxx', 'xyz')
Result: 'Tech'

It actually removes the individual occurrences of 'x', 'y', and 'z', as opposed to the pattern of 'xyz'.

The RTRIM function can also be used to remove all trailing numbers as demonstrated in the next example.

RTRIM('Tech6372', '0123456789')
Result: 'Tech'

In this example, every number combination from 0 to 9 has been listed in the trim_string parameter. By doing this, it does not matter the order that the numbers appear in string1, all trailing numbers will be removed by the RTRIM function.

转载于:https://www.cnblogs.com/Jeffrey-xu/p/4819565.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值