How to use substring to certain structure?


I have a text like this one:

“Hello this is just an 03920 example of 123456789 the text”

I would like to obtain this text:

“the text”

So what I want to achieve is to remove all the text (including) before a 9 numbers structure (in this case is 123456789).

Another example: “this example 109192312 of the text i want to obtain” --> “of the text i want to obtain”.

Thanks a bunch!

Take an int variable let’s say index. In this store the last index of the digit as:
yourString.LastIndexOfAny(new char[] { ‘1’, ‘2’,‘3’,‘4’,‘5’…so on });
And then substring using yourString.substring(index,yourstring.length()-1)
You will get the required text!!

Thank you so much!

1 Like