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

If a substring is found that matches my regular expression
pattern, I would like each character to be replaced with a
"*" character. I thought the following code would work,
but I'm missing something? :

'--------------------------------------------------------
Sub myregex()
Dim regEx As New VBScript_RegExp_55.RegExp
Dim str As String

str = "Call me at (982)555-1234!"

regEx.Pattern = "(...)...-...."
regEx.Global = True
regEx.IgnoreCase = True

MsgBox regEx.Replace(str, "*")

End Sub