替换网页文本中的空格的怪异问题 [英] weird problem with replacing space in text from a web-page
问题描述
您好,我有两行文字,在实际文字之前有较长的空格(更像是14-15空格).我已经尝试过简单的替换来拆分和合并,但是没有任何效果.我也尝试过修剪,最糟糕的是ascii给出的代码为32.但是没有任何效果.这是正文:
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 :
your heartburn symptoms
Certain foods, such as fat, chocolate, caffeine and alcohol can aggravate heartburn symptoms 1
Certain foods
(顺便说一句,它看起来并不像它.在我实际的richtextbox中,当我选择该空间时,它被选择为一个大的空间,例如标签,并且我也尝试替换vbtab但没有用)
我想要的是:
(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 :
your heartburn symptoms
Certain foods, such as fat, chocolate, caffeine and alcohol can aggravate heartburn symptoms 1
Certain foods
相信我,我已经尝试了几乎7-8种不同的功能,但是现在我发疯了.我的逻辑之一:
Believe me i have tried almost 7-8 diffferent function but now iam going mad. one of my logic :
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?
推荐答案
我要做的第一件事是查看您实际拥有的内容:使用string.ToCharArray
函数作为字符数组,或者使用System.Text.Encoding.ASCII.GetBytes
以字节为单位
使用调试器在代码上断点并继续执行,或者将其输出到文件中,以便您可以离线分析它.除非您知道数据的真实外观,否则您只是在猜测解决方案.
The first thing I would do is look at what you actually have: Either as an array of characters using thestring.ToCharArray
function, or as bytes usingSystem.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.
Dim lineArray As String() = rtfArticle.Lines
For z As Integer = 0 To lineArray.Length - 1
w(z) = lineArray(z).Trim()
这篇关于替换网页文本中的空格的怪异问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!