词条 | LTrim() |
释义 | LTrim()函数 去掉字符串截去首尾连续空白 . 表达式 String LTrim('源字符串'), '源字符串',输入类型为字符,需要处理的源字符串。 asp 实例: <% strTest = " This is a test!" response.write LTrim(strTest) %> 返回结果: This is a test! .net 实例: logic.aspx <%@ Page language="c#" AutoEventWireup="false" Inherits="NoahWeb.Engine" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>NoahWeb示范</title> </head> <body> <!-- #BeginLibraryItem "/Library/lout.lbi" -->逻辑层输出位点<!-- #EndLibraryItem --> </body> </html> 逻辑层示例 此示例需要存在文件"logic.aspx"和当前名称空间下具有"viewmsg"字符资源。 <Action name="logic.demo" NextAction=""> <Out Area="/Library/lout.lbi"> <SetVar Name="message" Value="'[' ADD LTrim(' a b c d ') ADD ']'" /> <Echo ContentLinkId="viewmsg" /> </Out> </Action> 示例输出 [a b c d] LTRIM删除起始空格后返回字符表达式。 语法 LTRIM ( character_expression ) 参数 character_expression 是字符或二进制数据表达式。character_expression 可以是常量、变量或列。character_expression 必须是可以隐性转换为 varchar 的数据类型。否则,使用 CAST 显式转换 character_expression。 varchar 注释 兼容级别可能影响返回值。有关兼容级别的更多信息,请参见 sp_dbcmptlevel。 示例 下例使用 LTRIM 字符删除字符变量中的起始空格。 DECLARE @string_to_trim varchar(60) SET @string_to_trim = ' Five spaces are at the beginning of this string.' SELECT 'Here is the string without the leading spaces: ' + LTRIM(@string_to_trim)GO 下面是结果集: ------------------------------------------------------------------------ Here is the string without the leading spaces: Five spaces are at the beginning of this string. (1 row(s) affected) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。