Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the (n) index of character inside String?

Tags:

java

suppose you have string like:

String longStr="someText1@someText2@someText3@someText@someText4@someText5@someText6@someText7@someText8@someText9@someText10@someText11@someText12@someText13@someText14";

how to get the index of the 10th occurrence of the @ character in the above String ?

i need the index to split from that index till the end.

like image 486
Mahmoud Saleh Avatar asked Nov 30 '22 11:11

Mahmoud Saleh


1 Answers

You can use StringUtils.ordinalIndexOf() to Find the n-th index within a String

like image 75
Alya'a Gamal Avatar answered Dec 12 '22 04:12

Alya'a Gamal