欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-06-18 10:18:32
提取中间文本(源文本 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