How to get last index with validation?

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 ##>

Last updated:11/4/2014 2:36:48 AM

1 Answers

Anonymous User
Anonymous User

I know this is a 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