這裏是我一起工作的典型字符串:正則表達式替換未去掉空格
· Identify & document site-related constraints and assumptions.
我想擦洗該字符串「確定」之前擺脫一切......
我寫了一個函數把字符串和擦洗,那就是:
Function dataScrub(dataIn As String)
Dim dataIn_orig As String
dataIn_orig = dataIn
'BEGIN : create and set regular expression
Dim regEx
Set regEx = CreateObject("vbscript.regexp")
With regEx
.IgnoreCase = True
.MultiLine = False
.Pattern = "^[\s]*[·]+[\s]*"
.Global = True
End With
dataScrub = regEx.Replace(dataIn_orig, "")
End Function
對於一個未知的原因,取而代之的是更換·(不是句號,更像一顆子彈),但不能擺脫的foll的空間流,所以我的最終結果是:
Identify & document site-related constraints and assumptions.
當我使用在線測試儀(http://www.regular-expressions.info/javascriptexample.html)測試我正則表達式,它按預期工作。
我在做什麼錯?
我不認爲你的問題是與正則表達式,但與格式的文本。我正在玩一些東西,看看我能否實現它。我注意到這一點,因爲excel trim函數在正則表達式運行後不會刪除文本前面的空格 – 2009-12-29 19:08:52