Pagini recente » Cod sursa (job #1588269) | Cod sursa (job #1831505) | Cod sursa (job #175646) | Cod sursa (job #2916495) | Cod sursa (job #1355959)
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
try{
BufferedReader input = new BufferedReader(new InputStreamReader(new FileInputStream("convertor.in")));
PrintStream output = new PrintStream("convertor.out");
String line = null;
String sb = new String();
while((line = input.readLine()) != null){
sb += line;
}
input.close();
String [] s = sb.split("}\\s*\\]|}");
Pattern p = Pattern.compile("(\".*?\")\\s*:\\s*(\\w+|\".*?\")");
Matcher m = p.matcher(s[0]);
while(m.find()){
output.print(m.group(1).replace("\"", "") + ",");
}
output.println();
for(int i = 0; i < s.length; i++){
m = p.matcher(s[i]);
m.reset(s[i]);
while(m.find()) {
output.print(m.group(2).replace("\"", "") + ",");
}
output.println();
}
output.close();
}catch(Exception e){
e.printStackTrace();
}
}
}