提取中間文本(源文本 As String, 前導文本 As String, 結束文本 As String, Optional 移除文本 As String = "", Optional 忽略大小寫 As Boolean = True) ...
提取中間文本(源文本 As String, 前導文本 As String, 結束文本 As String, Optional 移除文本 As String = "", Optional 忽略大小寫 As Boolean = True)
1 Dim S As String = "name:ok,link:none,name:ok2,link:none2" 2 '提取字元串中"name:"到","之間的字元 3 Dim SP() As String = DSAPI.字串提取.提取所有中間文本(S, "name:", ",") 4 For Each M As String In SP 5 Console.WriteLine(M) 6 Next 7 '輸出 ok ok2 8 9 10 '提取字元串中"link:"到","之間的字元,由於後面的link後面沒有",",所以提取的時候後面補一下,使得最後一個link也能被捕捉進來 11 SP = DSAPI.字串提取.提取所有中間文本(S & ",", "link:", ",") 12 For Each M As String In SP 13 Console.WriteLine(M) 14 Next 15 '輸出 none none2 16 17 18 '提取字元串中的"name:"到",",但只提取第一個匹配的。 19 Console.WriteLine(DSAPI.字串提取.提取中間文本(S, "name:", ",")) 20 '輸出 ok