Dim input As String = "Test,""Blah, Blah, Blah"",Test1,Test2"
Dim BeforeQuotes As String = input.Substring(0, input.IndexOf(""""c))
Dim BetweenQuotes As String = input.Substring(input.IndexOf(""""c), input.LastIndexOf(""""c) - input.IndexOf(""""c) + 1)
Dim AfterQuotes As String = input.Substring(input.LastIndexOf(""""c) + 1, input.Length - (input.LastIndexOf(""""c) + 1))
Console.WriteLine("Before quotes: " & BeforeQuotes)
Console.WriteLine("Between quotes: " & BetweenQuotes)
Console.WriteLine("After quotes: " & AfterQuotes)
Console.WriteLine("Fixed BetweenQuotes: " & BetweenQuotes.Replace(","c, String.Empty))
Console.WriteLine("All the portions Joined back: " & BeforeQuotes & BetweenQuotes & AfterQuotes)
TextFieldParser will handle that also, since it's just another field.turns out I need it to be able to do it more than once in a string.e.g.
Dim text As String = "Test, ""Blah, Blah, Blah"", Test1, Test2, Test3,""Test4, Test5"""
Dim rx As New Regex("""[^""\r\n]*")
Dim result As String = rx.Replace(text, AddressOf removeCommas)
Function removeCommas(ByVal m As Match) As String
Dim x As String = m.ToString()
x = Replace(x, ",", "")
Return x
End Function
Dim pattern As String = """[^""\r\n]*"""
Return m.Value.Replace(",", String.Empty)
.Replace("""", String.Empty)