Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15705

[RESOLVED] Coloring Text in Between Tags

$
0
0
Hi,

I know what Regex is, but I am not skilled in it.

Using a Richtextbox

All I need to do is color the text in between tags (these are not html tags) like this...

<S>H430</S> or <S>G7805</S>

All I need colored is the letter and the numbers. I will only have one H or G for the letter.

This is my code, but doesn't work.. I am sure I have the pattern wrong

Code:

Imports System.Text.RegularExpressions

Dim MyRegex As New Regex("<S>,</S>")
Dim MC As MatchCollection = MyRegex.Matches(txtChapter.Text)
Dim OldSel As Integer = txtChapter.SelectionStart

For Each M As Match In MC
  txtChapter.SelectionStart = M.Index
  txtChapter.SelectionLength = M.Value.Length
  txtChapter.SelectionColor = Color.Red
Next

txtChapter.SelectionStart = OldSel

I am not sure how to setup my regex pattern for <S> or </S> to color all the text in between these two tags.

Any help to point me in the right direction would be appreciated.

Viewing all articles
Browse latest Browse all 15705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>