CFIL
asked on
separate (") Char on a file (console application)
Dear experts,
I have a problem of separating some text with String.Split() function, the text is like this
The text is look like this:
"1", "Hi", "Test"
"2", "Hello", "B"
I have learned here to divied it by (,) chat, by this code:
Dim values() As String
For Each sLine In arrText
values = sLine.Split(",")
For i As Integer = 0 To values.GetUpperBound(0)
Console.WriteLine(i & ": " & values(i))
Next
Next
The output will be like this:
0: "1"
1: "Hi"
2: "Test"
0: "2"
1: "Hello"
2: "B"
How can sepearte them again by this (") char, I guess there is sonething like this in other langugeraes:
values = sLine.Split('"%"')
So I want the output like this:
0: 1
1: Hi
2: Test
0: 2
1: Hello
2: B
Hope to find answers and thanks in advannce,
Regards.
I have a problem of separating some text with String.Split() function, the text is like this
The text is look like this:
"1", "Hi", "Test"
"2", "Hello", "B"
I have learned here to divied it by (,) chat, by this code:
Dim values() As String
For Each sLine In arrText
values = sLine.Split(",")
For i As Integer = 0 To values.GetUpperBound(0)
Console.WriteLine(i & ": " & values(i))
Next
Next
The output will be like this:
0: "1"
1: "Hi"
2: "Test"
0: "2"
1: "Hello"
2: "B"
How can sepearte them again by this (") char, I guess there is sonething like this in other langugeraes:
values = sLine.Split('"%"')
So I want the output like this:
0: 1
1: Hi
2: Test
0: 2
1: Hello
2: B
Hope to find answers and thanks in advannce,
Regards.
ASKER
Hi,
I want to delete all the quotes and (,) so the result should be something like this:
0: 1
1: Hi
2: Test
0: 2
1: Hello
2: B
Thanks in advance
I want to delete all the quotes and (,) so the result should be something like this:
0: 1
1: Hi
2: Test
0: 2
1: Hello
2: B
Thanks in advance
so:
Dim values() As String
For Each sLine In arrText
values = sLine.Split(",")
For i As Integer = 0 To values.GetUpperBound(0)
Console.WriteLine(i & ": " & values(i).Replace('"', '') )
Next
Next
ASKER
Hi, Thanks for the reply,
I have got this error:
Error 1 Expression expected.
I have got this error:
Error 1 Expression expected.
ASKER
The error in this line:
Console.WriteLine(i & ": " & values(i).Replace('"', '') )
Console.WriteLine(i & ": " & values(i).Replace('"', '') )
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Grate, thanks man for the help.
ASKER
Thx
check out the string functions for Replace, TrimLeft and TrimRight, to start with