Created
June 4, 2017 12:48
-
-
Save ndthanh/8d8516b8c187beac527fe2a272c610c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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