使用vb.net提取段落的一部分

时间:2013-11-08 08:26:26

标签: vb.net string

我有以下段落:

通过findyourfate.comhttp://www.findyourfate.com获取免费每日星座运势很好并且越来越好 - 你需要学习如何接受这个事实。虽然这可能听起来像轻浮或讽刺的建议,但事实是,最近,当命运在你的道路上抛出一些玫瑰花瓣时,你选择将它们视为更多的碎片 - 如果你选择看到它们的话。醒来,聪明起来。你需要开始承认礼物作为礼物给你。您需要了解自己的价值。http://www.findyourfate.com/rss/dailyhoroscope-feed.asp?sign=Aries [返回递送报告]

我使用vb.net存储在字符串中。

如何拆分该字符串以仅输出以下部分:

事情变得越来越好,而且你需要学习如何接受这个事实。虽然这可能听起来像轻浮或讽刺的建议,但事实是,最近,当命运在你的道路上抛出一些玫瑰花瓣时,你选择将它们视为更多的碎片 - 如果你选择看到它们的话。醒来,聪明起来。你需要开始承认礼物作为礼物给你。你需要了解自己的价值。

1 个答案:

答案 0 :(得分:0)

如果您有相同的段落,并且每次需要获得相同的输出,您可以使用替换而不是拆分它更容易:

 Dim texts As String = "Free Daily Horoscope by findyourfate.comhttp://www.findyourfate.comThings are good and getting better -- and you need to learn how to accept this fact. While this may sound like flippant or sarcastic advice, the truth is that lately, whenever the fates have thrown a few rose petals in your path, you have chosen to see them as just more debris -- if you have elected to see them at all. Wake up and wise up. You need to start acknowledging the gifts as gifts meant for you. You need to understand just how worthy of them you are.http://www.findyourfate.com/rss/dailyhoroscope-feed.asp?sign=Aries [return delivery report]"

    texts = texts.Replace("Free Daily Horoscope by findyourfate.comhttp://www.findyourfate.com", "")

    texts = texts.Replace("http://www.findyourfate.com/rss/dailyhoroscope-feed.asp?sign=Aries [return delivery report]", "")

如果你总是

,你会得到同样的结果

如果您想使用拆分:

Dim arraytext() As String

    arraytext = Split(texts, "Free Daily Horoscope by findyourfate.comhttp://www.findyourfate.com")

    arraytext = Split(arraytext(1), "http://www.findyourfate.com/rss/dailyhoroscope-feed.asp?sign=Aries [return delivery report]")

MsgBox(arraytext(0))