Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey,

I want to select the text between a prefix and a suffix in a richTextBox to show physical formulas.
How can I do this?

What I have tried:

This is the code I need for text formation:

C#
private void highText(RichTextBox rtb, int Start, string Text, int FontSize)
        {
            rtb.SelectionStart = Start;
            rtb.SelectionLength = Text.Length;
            rtb.SelectionCharOffset = 4;
            rtb.SelectionFont = new Font("Microsoft Sans Serif", FontSize);
        }

        private void lowText(RichTextBox rtb, int Start, string Text, int FontSize)
        {
            rtb.SelectionStart = Start;
            rtb.SelectionLength = Text.Length;
            rtb.SelectionCharOffset = -4;
            rtb.SelectionFont = new Font("Microsoft Sans Serif", FontSize);

        }
Posted
Updated 7-May-16 8:31am
v2
Comments
Karthik_Mahalingam 7-May-16 22:40pm    
give some example

1 solution

You should learn about RegEx (regular Expressions)
Regex Class (System.Text.RegularExpressions)[^]
Regular Expression Language - Quick Reference[^]

Google for more
 
Share this answer
 
Comments
Tobias Wälde 8-May-16 6:38am    
Thank you, I'm going to try it.

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