How do I get the after last two semicolon's occurrences of a string ?
Example:
Mobiles;Students;Test;Yes;1234
The output should be Yes;1234
CodePudding user response:
Using a regex replacement, we can try:
String input = "Mobiles;Students;Test;Yes;1234";
String output = input.replaceAll("^.*;([^;] ;[^;] )$", "$1");
System.out.println(output); // Yes;1234