I have the following System.Text.Reg ularExpressions .Regex that is supposed
to remove this predefined list of garbage characters from contact names that
come in on import files :
Dim _dropContactGar bage As New Regex( _
"([" & Chr(0) & "-" & Chr(31) & "]+)|" & _
"([" & Chr(33) & "-" & Chr(38) & "]+)|" & _
"([" & Chr(40) & "-" & Chr(44) & "]+)|" & _
"([" & Chr(47) & "-" & Chr(47) & "]+)|" & _
"([" & Chr(58) & "-" & Chr(64) & "]+)|" & _
"([" & Chr(91) & "-" & Chr(96) & "]+)|" & _
"([" & Chr(123) & "-" & Chr(127) & "]+)|" & _
"([" & Chr(152) & "]+)|" & _
"([" & Chr(155) & "-" & Chr(159) & "]+)|" & _
"([" & Chr(166) & "-" & Chr(224) & "]+)|" & _
"([" & Chr(226) & "-" & Chr(255) & "]+)")
We use it like this:
value = _dropContactGar bage.Replace(va lue, "")
But the Regex constructor is throwing an ArgumentExcepti on whose Message
property says only "Parse ([". There is no inner exception. Normally, if I
have a string expression that's wrong, I would Console.WriteLi ne() it. But
in this case, it doesn't WriteLine correctly, because some of the characters
in the expression are control characters, so what it displays is not
visually correct.
I have slaved over this issue for hours and hours and I can only guess that
one of the items must be escaped with a "\" or something, but I cannot
figure it out. I have already been all over the MSDN help topics for the
Regex Class.
Help?
--
Peace & happy computing,
Mike Labosh, MCSD
"After very careful consideration, I have come
to the conclusion that this new system SUCKS"
-- General Barringer, from WARGAMES
to remove this predefined list of garbage characters from contact names that
come in on import files :
Dim _dropContactGar bage As New Regex( _
"([" & Chr(0) & "-" & Chr(31) & "]+)|" & _
"([" & Chr(33) & "-" & Chr(38) & "]+)|" & _
"([" & Chr(40) & "-" & Chr(44) & "]+)|" & _
"([" & Chr(47) & "-" & Chr(47) & "]+)|" & _
"([" & Chr(58) & "-" & Chr(64) & "]+)|" & _
"([" & Chr(91) & "-" & Chr(96) & "]+)|" & _
"([" & Chr(123) & "-" & Chr(127) & "]+)|" & _
"([" & Chr(152) & "]+)|" & _
"([" & Chr(155) & "-" & Chr(159) & "]+)|" & _
"([" & Chr(166) & "-" & Chr(224) & "]+)|" & _
"([" & Chr(226) & "-" & Chr(255) & "]+)")
We use it like this:
value = _dropContactGar bage.Replace(va lue, "")
But the Regex constructor is throwing an ArgumentExcepti on whose Message
property says only "Parse ([". There is no inner exception. Normally, if I
have a string expression that's wrong, I would Console.WriteLi ne() it. But
in this case, it doesn't WriteLine correctly, because some of the characters
in the expression are control characters, so what it displays is not
visually correct.
I have slaved over this issue for hours and hours and I can only guess that
one of the items must be escaped with a "\" or something, but I cannot
figure it out. I have already been all over the MSDN help topics for the
Regex Class.
Help?
--
Peace & happy computing,
Mike Labosh, MCSD
"After very careful consideration, I have come
to the conclusion that this new system SUCKS"
-- General Barringer, from WARGAMES
Comment