View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Remove characters from string

On Sun, 28 Jan 2007 07:37:29 GMT, Ken McLennan
wrote:

Set objRe = CreateObject("vbscript.regexp")


Is that a standard library? I'll have to check after my days off
to see if it's installed. If not then I'm out of luck (dammit!!) Still,
I'll just have to try it and see.


Yes, it is.

You could also set a reference (Tools/References) to Microsoft VBScript Regular
Expressions 5.5 and use this equivalent routine, which should run faster.

=============================
Option Explicit

Sub ParseNames()
Const T As String = "Name1 Name2 Name3 Name4"
Dim i As Long

Dim objRe As RegExp
Dim colMatches As MatchCollection

Const Pattern As String = "\w+"

Set objRe = New RegExp
objRe.Pattern = Pattern
objRe.Global = True

If objRe.test(T) = True Then
Set colMatches = objRe.Execute(T)

For i = 0 To colMatches.Count - 1
Debug.Print colMatches(i)
Next i

End If
End Sub

==========================
--ron