vb.net のテキスト ボックス内の単語から別の単語までを選択し、それらの間のすべてを強調表示したいと考えています。
例は
私はビーチに行き、家族とピクニックをして、6時に家に帰りました。
開始単語 behad
と終了単語 beinghome
と、その間のすべてが強調表示されます。
私はすでに少しコードを使用しています
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim a As String
Dim b As String
a = TextBox2.Text 'means what ever is in textbox2 string to the location where "a" is
b = InStr(RichTextBox1.Text, a)
If b Then
RichTextBox1.Focus()
RichTextBox1.SelectionStart = b - 1
RichTextBox1.SelectionLength = Len(a)
しかし、それはまさに私がやりたいことではありません。
これに加えて、以下に示すように正規表現関数を使用していました
'gets rid of the enter line break eg <enter> command no new lines
Dim content As String = Replace(TextBox1.Text, Global.Microsoft.VisualBasic.ChrW(10), Nothing)
'searches for this tag in the brackets between ".*" will be the contents
Dim Regex As New Regex("<div.*class=""answer_text"".*id=editorText"".*""")
'Show the string
For Each M As Match In Regex.Matches(content)
'This will get the values, there are 3 atm meta.name des and content
Dim Description As String = M.Value.Split("""").GetValue(3)
'displays the content in the label
TextBox3.Text = "" & Description
Next