Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm making an HTML editor in visual c#. But i need a regular expression pattern for finding html tags( "<>" and "<(slash)>") for code folding. There could be anything between those "<>". I'm using a textbox control called FastColoredTextBox by Pavel Torgashov.




It's 9:45 in my place. I'm having cold and my heads paining. Fast reply would be very much appreciated. Thanks in advance.
-TheKingofdemon33
Posted

Although you have solved your problem I am posting this to help those wanting to better use RegEx. A very helpful site is regexlib[^]; they have a large library of Regular Expressions. They also have a RegEx tester[^]. Also a very useful RegEx tool is available here.
 
Share this answer
 
Try this regex:
<(.+?)>


[EDIT]

If you want two regexes, then this is the first one, for finding <tag>
<[^/>]+>

And this is the second one, for finding </tag>
<\s*/[^>]+>
 
Share this answer
 
v3
Comments
TheKingofdemon33 18-Oct-13 14:15pm    
No. I have one for find "<>" and "<>". I want for "<>" and "</>"
Code(that i have):
range.SetFoldingMarkers(@"<|/>|", @"<|/>|");
Thomas Daniels 18-Oct-13 14:21pm    
I gave you one to find <tag> and </tag>
The first regex is to find <tag> and the second is to find </tag>
TheKingofdemon33 18-Oct-13 14:32pm    
Errors
Error 1: Unrecognized escape sequence C:\Users\User\Documents\Visual Studio 2012\Projects\CSharp HTML Editor\CSharp HTML Editor\Form1.cs
Line:130
Column: 52
Project: CSharp HTML Editor

Thomas Daniels 19-Oct-13 12:49pm    
You need to escape the backslash:
<\\s*/[^>]+>
Just replace the backslash with two backslashes.
I Solved this Question.
I used the in-built HTML highlighter and put an override for the highlighting of the words i needed. It had the code folding by default;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900