Thread: regEx replace
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default regEx replace

Hi Robert,

Am Thu, 2 Apr 2015 03:08:31 -0700 schrieb Robert Crandal:

If I wasn't clear, the output message should be:

*************

But, I would also be happy if the output was:
(***)***-****


try:

Sub ReplaceGlobal()
Dim str As String
Dim ptrn As String, re As Object

str = "Call me at (982)555-1234!"
ptrn = "[0-9]"


Set re = New RegExp
re.Pattern = ptrn
re.IgnoreCase = False
re.Global = True

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


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional