请高手们帮忙。
我的字符串如下:s="[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)"
希望得到result="[中国] [浙江] [江苏] "
即去除其他,保留全部含中括号的,中间用空格分割。
我的字符串如下:s="[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)"
希望得到result="[中国] [浙江] [江苏] "
即去除其他,保留全部含中括号的,中间用空格分割。
解决方案 »
- 关于ado更新数据时出现的“关闭对象时,不允许操作”问题
- vb修改数据的控件,vb这家伙怎这么变态
- 如何加密中文??谁能供献出精典代码?在线等待!
- 请问类名ComboBox的值是多少?
- 如何用VB检测一台机子有没有在上网呢
- 如何把一组坐标数据存成二进制文件?
- 求助:调用EXCEL出现加载DLL错误
- 数据库文件损坏应该怎么修复??加急!!高手请进!!!
- 浪费大家的眼光。我在这里有2个id xxlroad(土八路) 和 xxl_road(土八路)
- 我要用winhelp做一个帮助文件,但用word做主题文件时,$ # K却不管用(在word中)
- 关于 winsock的connect问题 懂ifix的最好
- 关于VB与数据库的问题
'引用Microsoft VBScript Regular Expressions 5.5.Private Sub Command1_Click()
Dim regexpObj As New RegExp
regexpObj.Pattern = "\[[\u4e00-\u9fa5]+\]"
regexpObj.Global = True
Dim matches, match, ret
Set matches = regexpObj.Execute("[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)")
For Each match In matches
ret = ret & " " & match.Value
Next
MsgBox ret
End Sub
Dim aa As String
Dim bb As String
Dim a As Integer
aa = "[weof] (wfndo) sfon ,[ww] nosdf n[a]"
For i = 1 To Len(aa)
If Mid(aa, i, 1) = "[" Then
a = 1
ElseIf Mid(aa, i, 1) = "]" Then
a = 2
Else
If a = 2 Then a = 0
End If
If a = 1 Then bb = bb & Mid(aa, i, 1)
If a = 2 Then bb = bb & "]"
Next iEnd SubPrivate Sub Command2_Click()'方法二
Dim aa As String
Dim bb As String
Dim a() As String
Dim b() As String
Dim i As Integer
Dim start As Integeraa = "[weof] (wfndo) sfon ,[ww] nosdf n[a]"
If Left(aa, 1) = "[" Then start = 1
a = Split(aa, "[")For i = start To UBound(a)
b = Split(a(i), "]")
bb = bb & "[" & b(0) & "]"
Next i
MsgBox bbEnd Sub
Private Sub Command1_Click()
Dim regexpObj As New RegExp
regexpObj.Pattern = "\[[\u4e00-\u9fa5]+\]"
regexpObj.Global = True
Dim matches, match, ret
S = "[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)"
Set matches = regexpObj.Execute(S)
S = regexpObj.Replace(S, "")
MsgBox S
For Each match In matches
ret = ret & " " & match.Value
Next
MsgBox ret
End Sub
源字符串:S = "[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)"
replace以后得到字符串:r= "[中国 [浙江][江苏]"
Dim regexpObj As New RegExp
regexpObj.Pattern = "\[[\u4e00-\u9fa5]+\]"
regexpObj.Global = True
Dim matches, match, ret
S = "[中国] (湖南)[浙江],海南、[江苏] *(黑龙江)"
Set matches = regexpObj.Execute(S)
For Each match In matches
ret = ret & " " & match.Value
Next
s=ret
MsgBox s
End Sub