Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Public Function lay_so(s As String) As String
Dim s2 As String
Dim replace_hyphen As String
replace_hyphen = " "
Set re = CreateObject("vbscript.regexp")
If re Is Nothing Then Set re = CreateObject("vbscript.regexp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "[^0-9 -]" 'includes space, if you want to exclude space "[^0-9]"
s2 = re.Replace(s, vbNullString)
re.Pattern = "[^0-9 ]"
lay_so = re.Replace(s2, replace_hyphen)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment