Pagini recente » Cod sursa (job #617651) | Cod sursa (job #145407) | Cod sursa (job #2755582) | Cod sursa (job #1084453) | Cod sursa (job #1355911)
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*\\]|}");
sb = "";
for(int i = 0; i < s.length; i++){
Matcher m = Pattern.compile("(\".*?\")\\s*:\\s*(\\w+|\".*?\")").matcher(s[i]);
while(m.find()) {
if(i == 0){
output.print(m.group(1).replace("\"", "") + ",");
sb += (m.group(2).replace("\"", "") + ",");
}
else{
output.print(m.group(2).replace("\"", "") + ",");
}
}
output.println();
if(i == 0){
output.println(sb);
}
}
output.close();
}catch(Exception e){
e.printStackTrace();
}
}
}