HOW TO GET LAST INDEX WITH VALIDATION?

Pooja Malohtra

Total Post:47

Points:331
Posted by  Pooja Malohtra
C#  Winforms 
 1048  View(s)
Ratings:
Rate this:

im doing some experiment on how can i get specific index of string in richTextBox Control .

scenario: I need to find lastIndex of #> but doesnt match with ##>

reason (2) ## will block #

heres what i started for now:

string text = richTextBox1.Text;
int lastIndexOffragment = text.LastIndexOf('#>');

Q: How can i find the real last Index of #> with validation thats its not ##>

  1. Chris S

    Post:48

    Points:336
    Re: How to get last index with validation?

    I know this is very ugly method but, i think this will be very easy and not complecated.

    str = "your string";
    
    int iLastIndex = str.Replace("##>", "^^>").LastIndexOf("#>");

    you can use any character instead of ^.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!