You do not need to avoid single quotes, only double quotes. Once a variable has been assigned with a string constant, it can be freely moved around and it will not change.
The only real problem that you encounter with a large regex is that it does not match because you left some βairβ in it.
This is what you have:
"^[ ]?([^\ ,()""'']+)(?:[ ](\(([^)]*?)\)))?[ ]((?:(([^\ ,()""''])[^\ ,()""'']*)[ ])([^\ ,()""'']+(?:[ ][^\ ,()""'']+)*))(?: [ ]? , [ ]?(.*?))?[ ]?(\(\s*'*\d*\s*\))[ ]?$"
This is what should be:
"^[ ]?([^\ ,()""']+)(?:[ ](\(([^)]*?)\)))?[ ]((?:(([^\ ,()""'])[^\ ,()""']*)[ ])([^\ ,()""']+(?:[ ][^\ ,()""']+)*))(?:[ ]?,[ ]?(.*?))?[ ]?(\(\s*'*\d*\s*\))[ ]?$"
Here is a test case with your regular expression (which only matches the multi-last form, if I remember):
Dim RXE As Object Dim RXNorm As Object Sub RegexColumnValueComparison() Dim strData As String Dim strPat As String Call InitializeRXs ' Here, the grad part ('#) is optional strPat = "^[ ]?([^\ ,()""']+)(?:[ ](\(([^)]*?)\)))?[ ]((?:(([^\ ,()""'])[^\ ,()""']*)[ ])([^\ ,()""']+(?:[ ][^\ ,()""']+)*))(?:[ ]?,[ ]?(.*?))?[ ]?(?:(\(\s*'*\d*\s*\))[ ]?)?$" ' Here, the grad part ('#) is required 'strPat = "^[ ]?([^\ ,()""']+)(?:[ ](\(([^)]*?)\)))?[ ]((?:(([^\ ,()""'])[^\ ,()""']*)[ ])([^\ ,()""']+(?:[ ][^\ ,()""']+)*))(?:[ ]?,[ ]?(.*?))?[ ]?(\(\s*'*\d*\s*\))[ ]?)$" strData = " John Bert Smith, Jr ('78) " MsgBox (RxRepl(strData, strPat, "$7 $8 , $1 $3 $6 $9")) End Sub Function RxRepl(sData As String, sPat As String, sRepl As String) As String sData = RXNorm.Replace(sData, " ") RXE.Pattern = sPat ' Can test for pass/fail .. 'If RXE.Test(sData) Then ' MsgBox ("matched pattern") 'Else ' MsgBox ("did NOT match pattern") 'End If RxRepl = RXE.Replace(sData, sRepl) End Function Sub InitializeRXs() Set RXE = CreateObject("vbscript.regexp") Set RXNorm = CreateObject("vbscript.regexp") RXE.Global = True RXNorm.Global = True RXNorm.Pattern = "\s+" End Sub