DSAPI 提取中间文本(字符串)

时间:2024-05-20 10:36:14

提取中间文本(源文本 As String, 前导文本 As String, 结束文本 As String, Optional 移除文本 As String = "", Optional 忽略大小写 As Boolean = True)

 Dim S As String = "name:ok,link:none,name:ok2,link:none2"
'提取字符串中"name:"到","之间的字符
Dim SP() As String = DSAPI.字串提取.提取所有中间文本(S, "name:", ",")
For Each M As String In SP
Console.WriteLine(M)
Next
'输出 ok ok2 '提取字符串中"link:"到","之间的字符,由于后面的link后面没有",",所以提取的时候后面补一下,使得最后一个link也能被捕捉进来
SP = DSAPI.字串提取.提取所有中间文本(S & ",", "link:", ",")
For Each M As String In SP
Console.WriteLine(M)
Next
'输出 none none2 '提取字符串中的"name:"到",",但只提取第一个匹配的。
Console.WriteLine(DSAPI.字串提取.提取中间文本(S, "name:", ","))
'输出 ok