Home > DeveloperSection > Forums > How to get last index with validation?
Pooja Malohtra
Pooja Malohtra

Total Post:47

Points:331
Posted on    November-03-2014 11:41 PM

 .NET C#  Winforms 
Ratings:


 1 Reply(s)
 717  View(s)
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 ##>



Chris S
Chris S

Total Post:48

Points:336
Posted on    November-04-2014 2:36 AM

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 ^.


Don't want to miss updates? Please click the below button!

Follow MindStick