假设有这样一个字符串tmpStr="123 32 32 112",如何通过正则表达式来把所有的连续空格替换为一个?谢谢
解决方案 »
- 关于print的分号与Tab
- 简单的聚焦问题就是解决不了
- DataGrid与Adodc控件绑定之后的Addnew和Update问题?
- 通过VB ADO ODBC连接SQLSERVER为何30秒它会自己确认连接,有没有方法把30改大
- 用label控件要怎么实现鼠标经过时换图,鼠标一移开就换回原来的图??
- 高手解决怎样让一个窗体跟着你的鼠标走?
- VB如何从打印端口截取打印数据? 有没有这方面的资料或控件? 万分感谢
- 请问关于SQL语句的问题
- 请教Ado的针对各种数据源的ConnectiongString详细说明(一定要包括dbase dbf,foxpro,sql的,其余不限,多多益善)
- 大家帮我看看这个怎么编http://go.6to23.com/perfecthomepage/cc.exe
- 使用ODBC非DSN连接Sql Server 数据库出错,请大虾来看看是怎么回事!
- 今天在网上下了一个 VB 6.0 怎么就是装不上去呢?
Dim i As Long
Dim txt As String
txt = Text1.Text
Do
i = InStr(1, txt, Space(2))
If i = 0 Then Exit Do
txt = Replace(txt, Space(2), Space(1))
Loop
Text1 = txt
End Sub
http://www.regexlab.com/zh/replshop.asp?pat=%5Cs%2B&rto=%3F&txt=123%2032%20%20%20%2032%20%20112
tmpStr = Replace(tmpStr, " ", " ")
Wend
Dim Reg As New RegExp
Dim strSource As String, strReplace As String
Dim strPattern As String
strSource = "4324 432 432 432 432432 423 432 324 32 432 4 32"
strReplace = " " '这里是一个空格
strPattern = "\x20{2,}"
Reg.Pattern = strPattern
While Reg.Test(strSource) = True
strSource = Reg.Replace(strSource, strReplace)
Wend
Set Reg = Nothing
MsgBox strSource
End Sub-------
www.vicmiao.com
努力就有美好时光!