如一個變量 strType = "<A1>212<B1:C2>222<D1,D3>"
請教怎樣將strType里面被<>包含的字符拿出來放到數組呢?
結果
astrTemp(0)="<A1>"
astrTemp(1)="<B1:C2>
astrTemp(2)="<D1,D3>"
請教怎樣將strType里面被<>包含的字符拿出來放到數組呢?
結果
astrTemp(0)="<A1>"
astrTemp(1)="<B1:C2>
astrTemp(2)="<D1,D3>"
解决方案 »
- 如何仿XP系统自带的图片查看器
- 向数据库添加出错!
- VB语言在PCB行业中的应用
- 有两个关于Hook的函数有什么用?
- 请问用OLEDragDrop 拖动超连接,地址是获得了,但连接的文本怎么获得呢?必给分!
- 如何防止用户删除或修改注册表中的键值?
- VBA+word开发的程序编译成exe以后,运行的时候不能碰word??(高手帮我看看)
- VB里面有没有宏替换函数的?像foxpro的&xxx一样
- 在TREEVIEW控件中的问题。。。
- vb打包运行时,提示运行时错误’-2147217900(80040e14)’未知
- 新手问下,如何用VB写一个删除未知文件夹内的已知文件呢?
- 求VB高人一名,求师或有偿写个东西!
Dim strP() As String
Dim strT() As String
Dim astrTemp(0 To 2) As String
Dim strType As String
strType = "<A1>212 <B1:C2>222 <D1,D3>"
strP = Split(strType, "212")
strT = Split(strP(1), "222")
astrTemp(0) = strP(0)
astrTemp(1) = strT(0)
astrTemp(2) = strT(1)
Debug.Print astrTemp(0)
Debug.Print astrTemp(1)
Debug.Print astrTemp(2)
End Sub
'引用Microsoft VBScript Regular Expressions 5.5
Dim re As RegExp
Dim astrTemp()
Dim i
Dim mh As Match
Dim mhs As MatchCollection
Dim strType As String
strType = " <A1>212 <B1:C2>222 <D1,D3>"
Set re = New RegExp
re.Global = True
re.Pattern = "<[\u4e00-\u9fa5\S]*>" '同样是匹配地址,注意和上例的不同
Set mhs = re.Execute(strType)
For Each mh In mhs
ReDim Preserve astrTemp(i)
astrTemp(i) = mh
Debug.Print astrTemp(i)
i = i + 1
Next
End Sub
dim strType as string
dim tmp
dim i as long
strType = " <A1>212 <B1:C2>222 <D1,D3>"
tmp=split(trim(strType),"<")
for i=1 to ubound(tmp)
tmp(i)="<" & mid(tmp(i),1,instr(tmp(i),">"))
next
debug.? join(tmp)