LTrim、RTrim 和 Trim 函数 您所在的位置:网站首页 oracle中rtrim函数 LTrim、RTrim 和 Trim 函数

LTrim、RTrim 和 Trim 函数

2023-05-05 12:59| 来源: 网络整理| 查看: 265

返回一个 Variant (字符串) ,其中包含指定字符串的副本,其中不包含前导空格 (LTrim) 、尾随空格 (RTrim) ,或者前导和尾随空格 (Trim) 。

语法

LTrim ( 字符串)

RTrim ( 字符串)

剪裁 ( 字符串)

所需的 字符串参数 任何有效的 字符串表达式 。 如果字符串包含 Null,则返回 Null。

查询示例

表达式

结果

SELECT LTrim (ProductDesc) AS Expr1 FROM ProductSales;

返回字段"ProductDesc"中的字符串值(不带前导空格)并显示在 Expr1 列中。

SELECT RTrim (ProductDesc) AS Expr1 FROM ProductSales;

返回字段"ProductDesc"(不含尾随空格)中的字符串值,并显示在 Expr1 列中。

SELECT LTrim (ProductDesc) AS NoTrailingSpace FROM ProductSales;

返回字段"ProductDesc"(不带前导空格)中的字符串值,并显示在"NoTrailingSpace"列中。

SELECT RTrim (ProductDesc) AS NoLeadingSpace FROM ProductSales;

返回字段"ProductDesc"(不含尾随空格)中的字符串值,并显示在"NoLeadingSpaces"列中。

SELECT Trim (ProductDesc) AS Trimmed FROM ProductSales;

返回字段"ProductDesc"(不含前导空格和尾随空格)中的字符串值,并显示在"已修剪"列中。

VBA 示例

注意: 以下示例演示了在 VBA Visual Basic for Applications (模块) 函数。 有关使用 VBA 的信息,请在"搜索"旁边的下拉列表中选择"开发人员参考",在搜索框中输入一个或多个术语。

此示例使用 LTrim 函数来条带前导空格,使用 RTrim 函数从字符串变量中去除尾随空格。 它使用 Trim 函数来条带两种类型的空格。

Dim MyString, TrimStringMyString = " " ' Initialize string.TrimString = LTrim(MyString) ' TrimString = " ".TrimString = RTrim(MyString)' TrimString = " ".TrimString = LTrim(RTrim(MyString)) ' TrimString = "".' Using the Trim function alone' achieves the same result.TrimString = Trim(MyString) ' TrimString = "".

字符串函数以及如何使用它们



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有