---
title: "How to get last index with validation?"  
description: "How to get last index with validation?"  
author: "Anonymous User"  
published: 2014-11-03  
updated: 2014-11-04  
canonical: https://www.mindstick.com/forum/2505/how-to-get-last-index-with-validation  
category: ".net"  
tags: ["c#", "winforms"]  
reading_time: 1 minute  

---

# How to get last index with validation?

im doing some [experiment](https://answers.mindstick.com/qa/43405/who-created-the-holy-experiment) on how can i get specific [index](https://www.mindstick.com/blog/198/index-in-sql-server) of [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) in richTextBox [Control](https://www.mindstick.com/blog/197/asp-dot-net-repeater-control) .

[scenario](https://yourviews.mindstick.com/view/81221/sports-will-change-the-education-scenario): I need to find lastIndex of #> but doesnt [match](https://www.mindstick.com/forum/159713/regex-match-attribute-in-an-html-code) with ##>

reason (2) ## will [block](https://www.mindstick.com/forum/157599/explain-the-process-control-block-pcb-in-the-operating-system) #

heres what i started for [now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now):

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

Q: How can i find the real last Index of #> with [validation](https://www.mindstick.com/articles/12234/validation-using-data-annotation-using-entity-framework) thats its not ##>

## Replies

### Reply by 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 ^.


---

Original Source: https://www.mindstick.com/forum/2505/how-to-get-last-index-with-validation

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
