https://school.programmers.co.kr/learn/courses/30/lessons/12918
class Solution {
public boolean solution(String s) {
boolean answer = true;
if(s.length()!=4 && s.length()!=6){
return false;
}
else{
char str[]=s.toCharArray();
for(int i=0;i<str.length;i++){
if(!(str[i]>='0'&&str[i]<='9')){
return false;
}
}
}
return answer;
}
}
https://school.programmers.co.kr/learn/courses/30/lessons/60057?language=java
https://school.programmers.co.kr/learn/courses/30/lessons/64064
https://www.acmicpc.net/problem/3568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class boj3568{
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String input=br.readLine().replace(",","").replace(";","");
String[] str=input.split(" ");
String common=str[0];
for(int i=1;i< str.length;i++){
String[] vars=reverse(str[i]).split("#");
System.out.println(common+vars[0]+" "+vars[1]+";");
}
}
private static String reverse(String str){
char[] chars=str.toCharArray();
StringBuilder sb=new StringBuilder();
for(int pos=chars.length-1;pos>=0;--pos){
if(chars[pos]=='&' || chars[pos]=='*'){
sb.append(chars[pos]);
}
else if(chars[pos]==']'){
sb.append("[]");
pos--;
}
else if(chars[pos]>='a' && chars[pos]<='z'){
sb.append('#');
for(int j=0;j<=pos;j++){
sb.append(chars[j]);
}
break;
}
}
return sb.toString();
}
}