wildrobo
asked on
RegExp find tags
I have a long string that has tags i.e. <row> <cell> etc.
I would like to use a regexp to find all the occurences
I.E.
Dim re As New Regex("<.+>")
Dim mc As MatchCollection = re.Matches(rtbFormattedTex t.Text)
Dim m As Match
For Each m In mc
Console.WriteLine(m.ToStri ng)
Next
the problem is it returns the following line as a single match
<f name="Nobel-Regular"><z newsize="24.0"><color name="LexusGold">
How do I return each <*> using regexp?
The point I am trying to acheive is
The text is in a richtext box, when the text changes in the box, I want to go through and highlight all the tags. Anything in <>. I was going to use a regexp then find the position start of the match in the RTB and the length, then highlight it. If anyone can think of a better way, I will except that as well.
Thanks
I would like to use a regexp to find all the occurences
I.E.
Dim re As New Regex("<.+>")
Dim mc As MatchCollection = re.Matches(rtbFormattedTex
Dim m As Match
For Each m In mc
Console.WriteLine(m.ToStri
Next
the problem is it returns the following line as a single match
<f name="Nobel-Regular"><z newsize="24.0"><color name="LexusGold">
How do I return each <*> using regexp?
The point I am trying to acheive is
The text is in a richtext box, when the text changes in the box, I want to go through and highlight all the tags. Anything in <>. I was going to use a regexp then find the position start of the match in the RTB and the length, then highlight it. If anyone can think of a better way, I will except that as well.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome,
Thank you. Not only for the actual code, but more importantly for the explination. "Teach a man to fish...." right.
Thanks again.
Thank you. Not only for the actual code, but more importantly for the explination. "Teach a man to fish...." right.
Thanks again.
Not a problem, always glad to help if I can. ;=)
Dim re As New Regex("<.+?>")
Fernando