Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
I am comparing a large dataset by concatenating non-unique identifiers. However, when it comes to names, I'm not getting matches that I should. One of the issues is punctuation and name suffixes (LNAME, Jr., etc.). I thought a RegEx would do the trick, but I'm not that proficient yet.
My goal is to remove all punctuation from a string (easy; see below) but in also exclude certain name honorifics/suffixes (Mr, Mrs, Ms, Jr, Sr, III, etc) AND to keep my pipe-delimiter in the string (desired format: LASTNAME|FIRSTNAME). I know this is used as an OR in RegEx, but hopefully there's a workaround.
Thanks y'all.
My goal is to remove all punctuation from a string (easy; see below) but in also exclude certain name honorifics/suffixes (Mr, Mrs, Ms, Jr, Sr, III, etc) AND to keep my pipe-delimiter in the string (desired format: LASTNAME|FIRSTNAME). I know this is used as an OR in RegEx, but hopefully there's a workaround.
Thanks y'all.
Code:
Function RemovePunctuation(rts As String) As String
' ~~ Remove punctuation
' [URL]https://www.extendoffice.com/documents/excel/3296-excel-remove-all-punctuation.html[/URL]
With CreateObject("VBScript.RegExp")
.Pattern = "[^a-zA-Z0-9 ]"
.IgnoreCase = True
.Global = True
RemovePunctuation = .Replace(rts, vbNullString)
End With
End Function