How would I split the following string?
test, 7535, '1,830,000', '5,000,000'
The result should be
test
7535
'1,830,000'
'5,000,000'
I try:
Dim S() as string = mystring.split(",")
But I get,
test
7535
'1
830
000'
'5
000
000'
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t parse CSV manually when you have handy good quality libraries available. Please!
CSV parsing has many many potential pitfalls and this library, according to my testing, solves most of them neatly.
That said, if this is a one off task and the strings are always like your example, you can use regex, like this (VB.NET syntax might be wrong, please fix):
This counts on that there is always a space after the separating comma and that there is no space in the commas between the numbers. If that’s not always the case you can: