- OS : Windows 10 Version 21H1
- AutoIt : v3.3.16.0
- blog : 师万物
- typesetting : Markdown
script
Global $name = "lisa-john"
;转为字符串
;String ( expression )
;Returns the string representation of an expression.
ConsoleWrite(String(10))
ConsoleWrite(IsString(String(10)))
ConsoleWrite(@CRLF)
;字符串长度
;StringLen ( "string" )
;Returns the number of characters in a string.
ConsoleWrite(StringLen($name))
ConsoleWrite(@CRLF)
;截取
;StringMid ( "string", start [, count = -1] )
;Extracts a number of characters from a string.
ConsoleWrite(StringMid($name,3,2))
ConsoleWrite(@CRLF)
;左侧删除
;StringTrimLeft ( "string", count )
;Trims a number of characters from the left hand side of a string.
ConsoleWrite(StringTrimLeft($name,2))
ConsoleWrite(@CRLF)
;字符串替换
;StringReplace ( "string", "searchstring/start", "replacestring" [, occurrence = 0 [, casesense = 0]] )
;Replaces substrings in a string.
ConsoleWrite(StringReplace($name,'sa','li'))
ConsoleWrite(@CRLF)
;字符串分割
;StringSplit ( "string", "delimiters" [, flag = 0] )
;Splits up a string into substrings depending on the given delimiters.
Global $arr[] = StringSplit($name,'-')
ConsoleWrite(UBound($arr))
For $i In $arr
ConsoleWrite($i)
Next
ConsoleWrite(@CRLF)
;判断是否只有大写字符
;StringIsUpper ( "string" )
;Checks if a string contains only uppercase characters.
ConsoleWrite(StringIsUpper($name))
ConsoleWrite(@CRLF)
Go
>"D:\Develop\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "E:\autoit\demo.au3"
101
9
sa
sa-john
lili-john
32lisajohn
0
>Exit code: 0
学习资源
感恩曾经帮助过 师万物 的人。 学习AutoIt时,要多看官方的帮助文档,很有帮助的。 学有余力的话,可以了解CMD、VBA、PowerShell和RPA。 欢迎关注公众号:悟为生心