<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # String Method [TOC] # 介紹 1. 是一個依靠[元編程](http://xrvu_zen.gitee.io/wyagd001.github.io/docs/Objects.htm#Meta_Functions)實現的 String 方法,并非類。 2. 主要包含對于 String 的各種增強操作, 包括但不限于 獲取長度,獲取單個字符,轉為字符數組,提取漢字漢語拼音首字母... 3. 關于元編程的更多內容,可參考以下文檔 - [AHK官方文檔](https://autohotkey.com/docs/Objects.htm#Meta_Functions) - [AHK元編程入門系列教程(@心如止水)](https://zhuanlan.zhihu.com/AHKZen) - [AHK面向對象的編程教程(@jeeswg)](https://www.autohotkey.com/boards/viewtopic.php?f=7&t=54588) 4. 由于這些方法都非常基礎和簡單,所以按照官方文檔的處理方法(比如其對數學函數的處理方法),多個方法的文檔放在同一個頁面之中。 ### 定義常量 - 并非真實存在的,只是為了演示方便。 因為名字太常見,容易撞車。以后如果用得多了可能單獨放在一個類里面。 **Str:="MyHome"** **Zh:="那里有條美麗的河"** ### CharAt(index) - 提取字符 提取String中的字符 - 如果越界會拋出 IndexOutOfBounds 異常 **參數:** index - 索引 ``` autohotkey Str.CharAt(6) ;返回e Str.CharAt(7) ;拋出異常 Str.CharAt(0) ;拋出異常 ``` ### insert(insert,pos=1) - 插入字符串 在字符串中插入字符串。 如果`pos`>`length+1`,那么頭部位置依舊為`length+1`。 **參數:** insert- 被插入的字符串 pos - 被插入字符串在新字符串中的頭部位置 **測試:** 有 ### Length() - 獲取長度 獲取String的長度 ``` autohotkey Str.Length() ``` ### ToList() - 轉為數組 提取String中的字符 ``` autohotkey Str.ToList() ``` ### toHex() - 轉為十六進制(16進制) 如果不是數字會拋出"String is not Number"異常 ### py() - 獲取拼音首字母 轉換漢字字符串為首字母漢語拼音字符串 - 提取自 [HotWindows(@劉老六)](https://www.iplaysoft.com/p/hotwindows) ``` autohotkey Zh.py() ``` ### ExtractFileNameByPath() - 從路徑中提取文件名(帶后綴) 從路徑中提取文件名(帶后綴) ```autohotkey path=D:\BeanLib\StringMethod.ahk println(path.ExtractNameFromPath()) ``` ### SplitFileName() - 分割帶后綴文件名為單純的文件名和后綴名(提取后綴名) 分割帶后綴文件名為單純的文件名和后綴名(提取后綴名) ```autohotkey FileName=chrome.dll s:=FileName.SplitFileName() println(s[1]) println(s[2]) ``` ### isRegExMatch(aRegEx,aRegExOption:="i)") 檢查字符串是否能完全匹配正則表達式。 `PathObj` 中的路徑合法性檢查就是依賴這個實現的,如下: ```autohotkey af(){ aPath:=this.path aRegEx=^[a-zA-Z]:\\(((?![<>:"/\\|?*]).)+((?<![ .])\\)?)*$ absolutePathResult:=aPath.isRegExMatch(aRegEx) if Not(absolutePathResult){ Mes:=InvalidPara . "1" throwWithSt(Mes) } return } ``` ### isNumber() 檢查字符串是否為數字 其實就是檢查是否能夠完全匹配RegEx=[0-9]+ ```autohotkey LogPrintln("555".isNumber(),"""555"".isNumber() >>>") ``` ### minToMSec() 分鐘轉毫秒 ### secToMSec() 秒轉毫秒 ### replaceAll(aStringList,aReplaceString) 用多個關鍵詞替換字符串 ```AutoHotKey "ABCDEFG".replaceAll("ACG".ToList(),"") LogPrintln("ACG".ToList(),A_LineFile "(" A_LineNumber ")" " : " """ACG"".ToList() >>> `r`n") LogPrintln("ABCDEFG".replaceAll("ACG".ToList(),""),A_LineFile "(" A_LineNumber ")" " : " """ABCDEFG"".replaceAll(""ACG"".ToList(),"""") >>> `r`n") ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看