I have this kind of input
word w\'ord wo\'rd
I need to convert to uppercase both characters at the starts of the word and right after the <
Not as elegant as @Wiktor Stribizew post above but an attempt to do without regex:
public class HelloWorld{
public static void main(String []args){
String s ="word w'ord wo'r'd";
System.out.println(upperCase(s,'\''));
}
private static int x = 1;
private static String upperCase(String originalString, char delimeter)
{
if(originalString.length()==1)
{
return originalString;
}
int indexOfDelimeter = originalString.indexOf(delimeter);
StringBuilder result = new StringBuilder();
if(indexOfDelimeter<0)
{
return originalString;
}
String newBaseString = originalString.substring(indexOfDelimeter+2);
if(indexOfDelimeter==0)
{
result.append(delimeter).append(Character.toUpperCase(originalString.charAt(indexOfDelimeter+1))).append(newBaseString);
}
else
{
result.append(originalString.substring(0,indexOfDelimeter-1)).append(Character.toUpperCase(originalString.charAt(indexOfDelimeter-1))).append(delimeter).append(Character.toUpperCase(originalString.charAt(indexOfDelimeter+1)));
}
if(indexOfDelimeter