Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello i have two lines of text which have long space (more like 14-15 spaces) before the actual text. I have tried simple replace to split and merge but nothing is working. I have also tried trim and the worst thing is that ascii gives code of 32. But nothing works. here is the text :

C#
                                      your heartburn symptoms
Certain foods, such as fat, chocolate, caffeine and alcohol can aggravate heartburn symptoms 1
Certain foods



(BTW it's not like it looks it is. In my actual richtextbox, when i select the space it gets selected as one big piece of space like a tab and i have also tried replacing vbtab but no use)

What i want is :

C#
your heartburn symptoms
Certain foods, such as fat, chocolate, caffeine and alcohol can aggravate heartburn symptoms 1
Certain foods


Believe me i have tried almost 7-8 diffferent function but now iam going mad. one of my logic :

C#
Dim lineArray As String() = rtfArticle.Lines

            For z As Integer = 0 To lineArray.Length - 1
                Dim w As String() = lineArray(z).Split(" ")
                MsgBox(lineArray(z))
                Dim tmp As String = ""

                For Each s34 As String In w
                    If (s34 <> " ") Then
                        temp = temp & " " & s34
                    End If
                Next
                lineArray(z) = temp
            Next


it completely messes up the code. Any idea about this?
Posted

The first thing I would do is look at what you actually have: Either as an array of characters using the string.ToCharArray function, or as bytes using System.Text.Encoding.ASCII.GetBytes

Either use the debugger to breakpoint on the code and follow it through, or output to a file so you can analyse it offline. Until you know what you data actually looks like, you are just guessing as to a solution.
 
Share this answer
 
Comments
amit_upadhyay 1-Dec-11 3:32am    
hey thanks but i did get the ascii of the chars (substring till a char or digit is found) but it returned 32 which i suppose is space. Will getting it in bytes help me anyway ?
OriginalGriff 1-Dec-11 3:47am    
Did you check all of the characters? Or just the first one? You need to look a bit closer...
And yes, 32 (decimal) is a space character - but there are several space characters available in websites!
VB
Dim lineArray As String() = rtfArticle.Lines
For z As Integer = 0 To lineArray.Length - 1
    w(z) = lineArray(z).Trim()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900