Thread: regEx replace
View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_3_] Robert Crandal[_3_] is offline
external usenet poster
 
Posts: 161
Default regEx replace

"Claus Busch" wrote:

ptrn = "[\d{3}\d{2}\d{4}]"


Hmmm, I tried that with the following code, but it
didn't work:

Sub ReplaceGlobal()
Dim str As String
Dim ptrn As String
Dim re As New VBScript_RegExp_55.RegExp

str = "My SSN's are 123-45-6789 or 13434344-34-13300012664"

ptrn = "[\d{3}\d{2}\d{4}]"

re.Pattern = ptrn
re.IgnoreCase = False
re.Global = True

MsgBox re.Replace(str, "*")
End Sub