StringStripWS

首页  后退  前进

StringStripWS
down2

StringStripWS

删除字符串的空白符.

 

StringStripWS ( "string", flag )

参数

string

目标字符串

flag

指定执行的删除操作(多个操作可将相应数值相加):

   $STR_STRIPLEADING (1) = 删除开头的(左边)空白符

   $STR_STRIPTRAILING (2) = 删除结尾的(右边)空白符

   $STR_STRIPSPACES (4) = 删除2个(或更多)单词之间的空格

   $STR_STRIPALL (8) = 删除所有空格(忽略其它所有标志)

 

常量定义在 StringConstants.au3

返回值

返回删去指定空白符后的新字符串.

备注

空白符是指从 Chr(9) 到 Chr(13) 的所有字符, 包括:

水平制表符, 换行符, 垂直制表符, 换页符以及回车符.

还包括空字符串( Chr(0) )和标准空格符 ( Chr(32) ).

 

若要删除单词字符之间的单个空格符, 请使用函数 StringReplace().

 

函数示例

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
; Strip leading and trailing whitespace as well as the double spaces (or more) in between the words.
Local $sString = StringStripWS("   This   is   a   sentence   with   whitespace.    ", $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
MsgBox($MB_SYSTEMMODAL, "", $sString)

----------------------------------------

 

该函数可以通过命令 exect 调用

参见:

StringStripCR, StringIsSpace, StringReplace, StringRegExpReplace

例子
copy
$var_aa='~~~~Начало~~~и~~~~конец~~строки~~'

StringStripWS($var_aa,3)

 

exect=$var_s1=StringStripWS('~~это~~字符串~~текста~~',3)||$var_s2=StringStripWS('~~это~~字符串~~текста~~',8) GLOBALEXECT<a> ;; 删除空格符号符号在一行

up2

tcimage © Аверин Андрей для Total Commander Image Averin-And@yandex.ru