Case 1:
String str = "Test something Test";
I have to find Test and replace with it's occurrence number. Here Test appears two time. So the first occurrence shall be replaced with 1 and second occurrence replace with 2.
Expected output
"1 something 2"
This is just small string. It may contain more occurrence of Test in string/word.
Case 2:
String str = "TestsomethingTest";
Expected output
"1something2"
I tried with replace but it replace all occurrence with same number.
Aucun commentaire:
Enregistrer un commentaire