0

How to move punctuation

I am working on Pig Latin. In one of the rules, I have to move punctuation. Please give me some advice on how to move punctuation to the end of the translated word. This is my code so far. https://code.sololearn.com/cj85KNP32FI5

3rd Mar 2022, 8:12 PM
Lola
2 Respuestas
+ 6
String punctuation = ""; for (int i = str.length() - 1; i > 0; i--) { if (!Character.isLetter(str.charAt(i))) { punctuation = str.charAt(i) + punctuation; } else { break; // Found all punctuation } } str = str.substring(0, str.length() - punctuation.length()); // Remove punctuation // Convert str to pig latin // Append punctuation to str
4th Mar 2022, 4:45 AM
Vaibhav
Vaibhav - avatar
+ 1
Thank you!
9th Mar 2022, 7:24 AM
Lola