Function CreateReg(s As String) As String
Dim i As Long
Dim x As Long
Dim charCounter As Long
Dim currentCharType As String
Dim sOut As String
sOut = ""
charCounter = 1
currentCharType = CharType(Mid(s, 1, 1))
x = Len(s) + 1
For i = 2 To x
If (Not CharType(Mid(s, i, 1)) = currentCharType) Or (i = x) Then
sOut = sOut & currentCharType & "{" & charCounter & "}"
currentCharType = CharType(Mid(s, i, 1))
charCounter = 1
Else
charCounter = charCounter + 1
End If
Next i
CreateReg = sOut
End Function
Function CharType(s As String) As String
If s Like "[A-z]" Then
CharType = "[a-z]"
ElseIf s Like "[0-9]" Then
CharType = "[0-9]"
ElseIf s Like "*-*" Then
CharType = "[-]"
ElseIf s Like "* *" Then
CharType = "[ ]"
ElseIf s Like "*/*" Then
CharType = "[//]"
ElseIf s Like "*.*" Then
CharType = "[.]"
ElseIf s Like "*(*" Then
CharType = "[(]"
ElseIf s Like "*)*" Then
CharType = "[)]"
ElseIf s Like "**" Then
CharType = "[\]"
ElseIf s Like "*+*" Then
CharType = "[+]"
ElseIf s Like "*<*" Then
CharType = "[<]"
ElseIf s Like "*>*" Then
CharType = "[>]"
ElseIf s Like "*~*" Then
CharType = "[~]"
Else
CharType = "X"
End If
End Function
|