Hi every one
I have a text file lines look like this
2.0 28 Blue (2 14.00 64.0) [T1 ] 40611 9275 81504 -49757
2.0 28 Blue (2 14.00 63.0) [T2 ] 42111 9275 82504 -49757
i want to swap the field in () and [].. So that it will look like this
2.0 28 Blue [T1 ] (2 14.00 64.0) 40611 9275 81504 -49757
2.0 28 Blue [T2 ] (2 14.00 63.0) 42111 9275 82504 -49757
my code is :
But this two lines:Code:Dim matchlines1() As String = IO.File.ReadAllLines("C:\kaya1.txt") For Each lines As String In matchlines1 Dim strBrackets As String Dim strParenthesis As String Dim w As Integer 'left square bracket Dim x As Integer 'right square bracket Dim y As Integer 'left parenthesis Dim z As Integer 'right parenthesis w = InStr(lines, "[") x = InStr(lines, "]") y = InStr(lines, "(") z = InStr(lines, ")") strBrackets = lines.Substring(w + 1, x - w - 1) strParenthesis = lines.Substring(y + 1, z - y -1) lines = lines.Replace(strBrackets, "xxx") lines = lines.Replace(strParenthesis, "yyy") lines = lines.Replace("xxx", strParenthesis) lines = lines.Replace("yyy", strBrackets) Next IO.File.WriteAllLines("C:\kaya1.txt", matchlines1)
Saying length can not be less than zero..strBrackets = lines.Substring(w + 1, x - w -1)
strParenthesis = lines.Substring(y + 1, z - y -1)
Can any one help me?
Thank you


Reply With Quote