online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *******************************************************************************/ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { String str = "{0=>[name:'data1',phone:'123',shipping:'location1'], \n" + "1=>[name:'data1',phone:'456',shipping:'location2'], \n" + "2=>[name:'data1',phone:'678',shipping:'location3'], \n" + "3=>[name:'data2',phone:'222',shipping:'location4'], \n" + "4=>[name:'data2',phone:'111',shipping:'location5'], \n" + "5=>[name:'data3',phone:'555',shipping:'location6']}"; HashMap<String,List<String>> result = new HashMap<String,List<String>>(); for (String string : str.split("=>")) { String s = string; Pattern p = Pattern.compile("\\[.*?\\]"); Matcher m = p.matcher(s); if(m.find()) { String element = (String) m.group().subSequence(1, m.group().length()-1); String key = element.split(":")[1].split(",")[0].replaceAll("'", "");// I am assuming you are not using any serialization API if(result.get(key) == null) { List<String> val=new ArrayList<String>(); val.add(element); result.put(key, val); }else { List<String> values= result.get(key); values.add(element); } } } result.forEach((k,v)->{ System.out.println(k+" => "+v ); }); } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue