-6

我是编程新手,我想知道如何在文本中进行如下搜索。

我有一个包含以下内容的文本

今天我赢了,仿佛他知道了真相,今天我清醒了,就像死了一样,与事物不再有血缘关系

我想要什么并搜索这个文本有这个词

真相如果你

我想存储一个字符串开头的单词“truth”,直到单词有意义,字符串将是

今天我真的很清醒,好像你死了,没有

并省略文本的其余部分。

我已经尝试搜索“真相”这个词的位置,但没有奏效。

4

1 回答 1

0

你的问题有点不清楚。

如果要在字符串中查找单词,可以使用函数 INSTR

Dim Position as integer = 0
Dim SampleText as String = "I won today as if he knew the truth Today I am lucid as if to die And had no more kinship with things"
'
Position = INSTR(SampleText, "truth")
if Position > 0 Then
  'matched
  msgbox("Word 'truth' found starting at position " & Position)
Else
  'not matched
  msgbox("Word 'truth' not found in text!")
End if
于 2015-06-28T00:17:37.863 回答